POST /v1/chat/completions is the OpenAI-compatible form for Claude. Set the Guard address, key and exact model in the SDK; other fields must follow the contract below. A server prompt is configured separately and does not require a different endpoint.
from openai import OpenAI
client = OpenAI(
api_key=KEY,
base_url="https://api.guardrelay.ai/v1",
)
resp = client.chat.completions.create(
model="claude-sonnet-5-5",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"},
],
)
print(resp.choices[0].message.content)All eight families work here. Accepted fields depend on the selected model and the family's native contract.
All seven Codex models accept Chat Completions JSON/SSE through both aliases, /v1/chat/completions and /codex/v1/chat/completions. Pass history in messages; the server does not invent continuation across Chat, Messages, and Responses.
curl https://api.guardrelay.ai/codex/v1/chat/completions \
-H "Authorization: Bearer $GUARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-astra",
"messages": [{"role": "user", "content": "Reply with exactly OK"}],
"stream": false
}'from openai import OpenAI
client = OpenAI(
api_key=KEY,
base_url="https://api.guardrelay.ai/v1",
)
resp = client.chat.completions.create(
model="k3",
messages=[{"role": "user", "content": "Hello!"}],
max_tokens=512,
)
print(resp.choices[0].message.content)from openai import OpenAI
client = OpenAI(
api_key=KEY,
base_url="https://api.guardrelay.ai/v1",
)
resp = client.chat.completions.create(
model="cursor-grok-4.6-medium",
messages=[{"role": "user", "content": "Hello!"}],
max_tokens=512,
)
print(resp.choices[0].message.content)from openai import OpenAI
client = OpenAI(
api_key=KEY,
base_url="https://api.guardrelay.ai/v1",
)
resp = client.chat.completions.create(
model="composer-2.5",
messages=[{"role": "user", "content": "Hello!"}],
max_tokens=512,
)
print(resp.choices[0].message.content)| What | How it works for Composer and Grok |
|---|---|
| Request fields | model, messages, max_tokens or max_completion_tokens, stream, tools |
| Both limits at once | max_tokens and max_completion_tokens in one request return 400; send one |
| Roles | user, assistant, plus system and developer as ordinary messages in the array |
| Content blocks | text blocks with exactly the type and text keys; Grok also takes image_url with inline base64 |
| Response | the ordinary OpenAI shape: choices[0].message.content, finish_reason: "stop", cache in usage.prompt_tokens_details.cached_tokens |
| Response with a tool call | choices[0].message.tool_calls with id, name and arguments, and finish_reason is tool_calls. You answer such a turn with a message whose role is tool |
Use POST /v1/chat/completions or POST /glm/v1/chat/completions. Send the full history in messages.
curl https://api.guardrelay.ai/glm/v1/chat/completions \
-H "Authorization: Bearer $GUARD_API_KEY" \
-H "content-type: application/json" \
-d '{"model":"glm-5.3","messages":[{"role":"user","content":"Reply with OK"}],"max_tokens":4096}'{
"id": "…",
"model": "glm-5.3",
"choices": [{
"message": {"role": "assistant", "content": "OK"},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 31,
"prompt_tokens_details": {"cached_tokens": 0},
"completion_tokens": 9,
"completion_tokens_details": {"reasoning_tokens": 0},
"total_tokens": 40
}
}| Field | Rule |
|---|---|
model | Exact glm-5.3 or glm-5.3-flash. |
messages | A non-empty array of message objects; preserve the assistant message during a tool roundtrip. |
max_tokens / max_completion_tokens | A positive integer; start with 4096. |
thinking | Confirmed disable shape: {"type":"disabled"}. |
stream_options.include_usage | Add it for terminal usage in SSE. |
Client functions arrive in choices[0].message.tool_calls; your application executes the function and appends a role: "tool" message with the same tool_call_id.
Built-in search uses only the native web_search object; OpenAI-like variants with other names are not part of the GLM contract.
Use POST /v1/chat/completions with an exact Gemini model. Send the full history in messages; without an explicit max_tokens the gateway uses 4096 tokens.
curl https://api.guardrelay.ai/v1/chat/completions \
-H "Authorization: Bearer $GUARD_API_KEY" \
-H "content-type: application/json" \
-d '{"model":"gemini-4-argon","messages":[{"role":"user","content":"Reply with OK"}],"max_tokens":4096}'Use POST /v1/chat/completions with an exact Muse model. Send the full history in messages.
curl https://api.guardrelay.ai/v1/chat/completions \
-H "Authorization: Bearer $GUARD_API_KEY" \
-H "content-type: application/json" \
-d '{"model":"muse-wonder-1.0","messages":[{"role":"user","content":"Reply with OK"}],"max_tokens":4096}'