Grok API
Quick start

Quick start with Grok API

Connect Grok to your application or coding tool and receive the first response in a few minutes.

GrokAPI uses the OpenAI-compatible protocol. In most integrations you only need to replace the API key, base URL, and model name.
1

Create an account and API key

Register, confirm your email, and then create a project key in the dashboard. Copy it once, it will not be shown in full again.

Create an account
2

Save the connection settings

Store credentials in environment variables. Do not commit real keys to git or expose them in browser code.

.env
GROK_API_KEY=sk-grok-YOUR_API_KEY
GROK_BASE_URL=https://api.llm-gate.tech/v1
3

Check the API with cURL

Send a minimal Chat Completions request. A successful response contains choices[0].message.content.

Terminal
curl https://api.llm-gate.tech/v1/chat/completions \
  -H "Authorization: Bearer sk-grok-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-4.5",
    "messages": [{"role": "user", "content": "Reply with: connection works"}],
    "stream": false
  }'
4

Connect the Python SDK

Install the official OpenAI SDK and pass the GrokAPI base URL to the client.

Terminal
pip install openai
Python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["GROK_API_KEY"],
    base_url="https://api.llm-gate.tech/v1",
)

response = client.chat.completions.create(
    model="grok-4.5",
    messages=[{"role": "user", "content": "Hello, Grok"}],
)
print(response.choices[0].message.content)
5

Connect the TypeScript SDK

The same OpenAI-compatible setup works in Node.js and server-side TypeScript applications.

Terminal
npm install openai
TypeScript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.GROK_API_KEY,
  baseURL: "https://api.llm-gate.tech/v1",
});

const response = await client.chat.completions.create({
  model: "grok-4.5",
  messages: [{ role: "user", content: "Hello, Grok" }],
});
console.log(response.choices[0].message.content);
6

Configure Cursor

Open Cursor Settings → Models, choose an OpenAI-compatible provider, and enter the values below.

Configuration
Provider: OpenAI Compatible
Base URL: https://api.llm-gate.tech/v1
API Key: sk-grok-YOUR_API_KEY
Model: grok-4.5
7

Configure Cline

Open Cline settings, select OpenAI Compatible, and fill in the base URL, API key, and model ID.

Configuration
API Provider: OpenAI Compatible
Base URL: https://api.llm-gate.tech/v1
API Key: sk-grok-YOUR_API_KEY
Model ID: grok-4.5

How to verify the connection

Ask the model to return a short answer. If streaming text appears and your dashboard balance changes, the connection is ready.

Common errors

401 Unauthorized: check the key and make sure it starts with sk-grok-.
404 Not Found: the base URL must include /v1.
429 Too Many Requests: wait and retry, or request higher limits.
Insufficient balance: top up the account or use the test credit.

Next steps