OpenAI Chat Completions
Send a request through RunAPI's OpenAI-compatible Chat Completions operation.
Overview
Use RunAPI's OpenAI-compatible Chat Completions operation with a compatible model and the protocol's request and response shapes.
Quick start
- Create an API key and set it as RUNAPI_API_KEY.
- Choose a compatible model, then send the documented path parameters and JSON body.
- Read the JSON response or server-sent events shown for this operation, and handle protocol errors.
Endpoint
- Base URL
https://runapi.ai- Contract version
v1- Preferred authentication
Authorization: Bearer YOUR_API_TOKEN
Authentication carriers
RunAPI accepts each carrier listed below. Generated samples use the protocol's preferred header.
- header - Preferred
Authorization: Bearer YOUR_API_TOKEN- header
x-api-key: YOUR_API_TOKEN- header
x-goog-api-key: YOUR_API_TOKEN- query
?key=YOUR_API_TOKEN
Compatible models
Open a model page for current pricing, rate limits, and commercial-usage details.
Show 53 compatible models
- claude-fable-5
- claude-sonnet-5
- claude-opus-5
- claude-opus-4-8
- claude-opus-4-7
- claude-opus-4-6
- claude-sonnet-4-6
- claude-opus-4-5-20251101
- claude-sonnet-4-5-20250929
- claude-haiku-4-5-20251001
- claude-opus-4-1-20250805
- gpt-5.5
- gpt-5.5-pro
- gpt-5.4
- gpt-5.4-mini
- gpt-5.4-nano
- gpt-5.4-pro
- gpt-5.3-codex
- gpt-5.3-codex-spark
- gpt-5.2
- gpt-5.2-pro
- gpt-5.6-luna
- gpt-5.6-sol
- gpt-5.6-terra
- gemini-3.5-flash
- gemini-3.1-pro-preview
- gemini-3-flash-preview
- gemini-2.5-pro
- gemini-2.5-flash
- deepseek-v4-pro
- deepseek-v4-flash
- glm-5.2
- glm-5.1
- glm-5-turbo
- glm-5
- glm-4.7
- glm-4.6
- glm-4.5
- glm-4.5-air
- kimi-k3
- kimi-k2.7-code
- kimi-k2.6
- kimi-k2.5
- MiniMax-M3
- MiniMax-M2.7
- MiniMax-M2.7-highspeed
- MiniMax-M2.5
- MiniMax-M2.5-highspeed
- MiniMax-M2.1
- MiniMax-M2
- grok-4.20-0309-non-reasoning
- grok-4.5
- grok-4.3
Request contract
Only fields with both public protocol and RunAPI support evidence are listed. Additional JSON body fields are passed through.
JSON body9 fields
max_tokens["integer", "null"]Compatibility generation token limit retained for supported models; model support can vary.
messagesarrayConversation messages in OpenAI Chat Completions format.
messages[].content["string", "array"]messages[].rolestringmodelstringRunAPI model identifier returned by the compatible model catalog.
stream["boolean", "null"]Return Chat Completions chunks as server-sent events.
Default:false
temperature["number", "null"]Sampling temperature; model support can vary.
toolsarrayTools the model may call.
top_p["number", "null"]Nucleus sampling probability; model support can vary.
Request example
{
"messages": [
{
"content": "Say hello in one sentence.",
"role": "user"
}
],
"model": "gpt-5.4",
"stream": false
}
Synchronous response
Schema
{
"additionalProperties": true,
"properties": {
"choices": {
"type": "array"
},
"created": {
"type": "integer"
},
"id": {
"type": "string"
},
"model": {
"type": "string"
},
"object": {
"const": "chat.completion",
"type": "string"
},
"usage": {
"additionalProperties": true,
"properties": {
"completion_tokens": {
"type": "integer"
},
"prompt_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
},
"required": [
"prompt_tokens",
"completion_tokens",
"total_tokens"
],
"type": "object"
}
},
"required": [
"id",
"object",
"created",
"model",
"choices"
],
"type": "object"
}
Example
{
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! How can I help today?",
"role": "assistant"
}
}
],
"created": 1785196800,
"id": "chatcmpl_example",
"model": "gpt-5.4",
"object": "chat.completion",
"usage": {
"completion_tokens": 8,
"prompt_tokens": 12,
"total_tokens": 20
}
}
SSE event: chunk
Schema
{
"additionalProperties": true,
"properties": {
"choices": {
"type": "array"
},
"created": {
"type": "integer"
},
"id": {
"type": "string"
},
"model": {
"type": "string"
},
"object": {
"const": "chat.completion.chunk",
"type": "string"
},
"usage": {
"oneOf": [
{
"additionalProperties": true,
"properties": {
"completion_tokens": {
"type": "integer"
},
"prompt_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
},
"required": [
"prompt_tokens",
"completion_tokens",
"total_tokens"
],
"type": "object"
},
{
"type": "null"
}
]
}
},
"required": [
"id",
"object",
"choices"
],
"type": "object"
}
Example
{
"choices": [
{
"delta": {
"content": "Hello"
},
"finish_reason": null,
"index": 0
}
],
"id": "chatcmpl_example",
"object": "chat.completion.chunk",
"usage": null
}
Protocol error: invalid_request
Schema
{
"additionalProperties": true,
"properties": {
"error": {
"additionalProperties": true,
"properties": {
"code": {
"type": [
"string",
"null"
]
},
"message": {
"type": "string"
},
"param": {
"type": [
"string",
"null"
]
},
"type": {
"type": "string"
}
},
"required": [
"message",
"type"
],
"type": "object"
}
},
"required": [
"error"
],
"type": "object"
}
Example
{
"error": {
"code": null,
"message": "messages is required",
"param": "messages",
"type": "invalid_request_error"
}
}
Usage
Schema
{
"additionalProperties": true,
"properties": {
"completion_tokens": {
"type": "integer"
},
"prompt_tokens": {
"type": "integer"
},
"total_tokens": {
"type": "integer"
}
},
"required": [
"prompt_tokens",
"completion_tokens",
"total_tokens"
],
"type": "object"
}
Example
{
"completion_tokens": 8,
"prompt_tokens": 12,
"total_tokens": 20
}
Generated Code Samples
Each cURL, JavaScript, and Python sample sends the validated request from this contract without requiring a protocol-specific SDK.
curl -X POST https://runapi.ai/v1/chat/completions \
-H Authorization:\ Bearer\ YOUR_API_TOKEN \
-H Content-Type:\ application/json \
-d \{\"model\":\"gpt-5.4\",\"messages\":\[\{\"role\":\"user\",\"content\":\"Say\ hello\ in\ one\ sentence.\"\}\],\"stream\":false\}
const response = await fetch("https://runapi.ai/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"model": "gpt-5.4",
"messages": [
{
"role": "user",
"content": "Say hello in one sentence."
}
],
"stream": false
})
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
console.log(data);
Install
pip install requests
import requests
response = requests.post(
"https://runapi.ai/v1/chat/completions",
headers={"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"},
json={"model": "gpt-5.4", "messages": [{"role": "user", "content": "Say hello in one sentence."}], "stream": False}
)
response.raise_for_status()
print(response.json())