RelayDanceRelayDance
HomeModelsPricingDocsGet API Key

Docs / API Reference / Chat Completions

POST/v1/chat/completions

Chat Completions

OpenAI-compatible endpoint for LLM chat. Supports streaming and tool calling. Drop-in replacement: change only the base URL and API key. On RelayDance the chat models are the Grok family (for example grok-4.3).

#Request body

ParameterTypeRequiredDescription
modelstringYesModel ID from your key's model list
messagesarrayYesArray of {role, content} objects. Roles: system | user | assistant
temperaturenumberNoSampling temperature 0 to 2. Default: 1
max_tokensintegerNoMax tokens to generate. Model limit applies if omitted
streambooleanNoIf true, stream tokens via SSE. Default: false
top_pnumberNoNucleus sampling, alternative to temperature
stopstring | arrayNoUp to 4 stop sequences
toolsarrayNoOpenAI tool-use schema for function calling

#Example request

terminalbash
curl https://relaydance.com/v1/chat/completions \
  -H "Authorization: Bearer $RELAYDANCE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-4.3",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user",   "content": "Explain quantum computing in 2 sentences."}
    ],
    "temperature": 0.7,
    "max_tokens": 256
  }'

#Response (non-streaming)

response.jsonjson
{
  "id":      "chatcmpl-abc123",
  "object":  "chat.completion",
  "created": 1749300000,
  "model":   "grok-4.3",
  "choices": [
    {
      "index":         0,
      "message":       { "role": "assistant", "content": "Quantum computing uses quantum bits..." },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens":     32,
    "completion_tokens": 48,
    "total_tokens":      80
  }
}

#Streaming

Set stream: true to receive tokens as Server-Sent Events:

stream_response.txttext
data: {"id":"chatcmpl-abc123","choices":[{"delta":{"content":"Quantum"},"index":0}]}
data: {"id":"chatcmpl-abc123","choices":[{"delta":{"content":" computing"},"index":0}]}
...
data: [DONE]

#Tool calling

tools.jsonjson
{
  "model": "grok-4.3",
  "messages": [{"role": "user", "content": "What's the weather in Tokyo?"}],
  "tools": [
    {
      "type": "function",
      "function": {
        "name":        "get_weather",
        "description": "Get the current weather for a location",
        "parameters": {
          "type": "object",
          "properties": {
            "location": {"type": "string", "description": "City name"}
          },
          "required": ["location"]
        }
      }
    }
  ]
}
Tool calling and parameter support vary by model. Unsupported parameters are ignored upstream.