Skip to content
API referenceChat Completions (OpenAI)

Chat Completions (OpenAI)

Chat Completions requests and replies for the selected model family.

Model protocol

Claude request

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.

python
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)

Kimi, Composer and Grok on this endpoint

All eight families work here. Accepted fields depend on the selected model and the family's native contract.

Codex on Chat Completions

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.

bash
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
  }'

Kimi request

python
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)

Grok request

python
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)

Composer request

python
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)
WhatHow it works for Composer and Grok
Request fieldsmodel, messages, max_tokens or max_completion_tokens, stream, tools
Both limits at oncemax_tokens and max_completion_tokens in one request return 400; send one
Rolesuser, assistant, plus system and developer as ordinary messages in the array
Content blockstext blocks with exactly the type and text keys; Grok also takes image_url with inline base64
Responsethe ordinary OpenAI shape: choices[0].message.content, finish_reason: "stop", cache in usage.prompt_tokens_details.cached_tokens
Response with a tool callchoices[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

GLM Chat Completions

Use POST /v1/chat/completions or POST /glm/v1/chat/completions. Send the full history in messages.

bash
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}'
json
{
  "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
  }
}
FieldRule
modelExact glm-5.3 or glm-5.3-flash.
messagesA non-empty array of message objects; preserve the assistant message during a tool roundtrip.
max_tokens / max_completion_tokensA positive integer; start with 4096.
thinkingConfirmed disable shape: {"type":"disabled"}.
stream_options.include_usageAdd 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.

Gemini Chat Completions

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.

bash
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}'

Muse Chat Completions

Use POST /v1/chat/completions with an exact Muse model. Send the full history in messages.

bash
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}'

Sections

On this page