Skip to content

OpenAI-compatible Chat Completions API reference

The OpenAI-compatible Chat Completions reference, with what each parameter does for Claude, GPT and Gemini models, streaming, examples and errors.

Updated October 3, 2026
On this page

Send a conversation and get the model's reply. This format works with Claude, GPT and Gemini models, so switching between them only means changing model.

POSThttps://api.5abeer.ai/v1/chat/completions

Authentication#

Send your key in the Authorization header as Bearer followed by the key. A key works with the models of the provider it was created for; see Keys and authentication. The base URL for this format:

OpenAI-compatiblehttps://api.5abeer.ai/v1Authorization: Bearer <KEY>
Anthropic-compatiblehttps://api.5abeer.aix-api-key: <KEY>
Geminihttps://api.5abeer.ai/v1betax-goog-api-key: <KEY>

Quick example#

curl --request POST "https://api.5abeer.ai/v1/chat/completions" \
  --header "Authorization: Bearer $KHABEER_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"model":"claude-sonnet-5.5","messages":[{"role":"user","content":"Write a product idea in one sentence."}]}'
Response
{
  "id": "chatcmpl-9f2",
  "object": "chat.completion",
  "model": "claude-sonnet-5.5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 12,
    "total_tokens": 33
  }
}

The key is read from KHABEER_API_KEY, so it never appears in your code.

Parameters#

Each row shows what happens to the parameter for each model family: supported means we pass it to the model; ignored means the request is accepted but the parameter has no effect, so don't rely on it; rejected means the request fails. We measured these against the gateway itself, not copied from the provider's documentation.

ParameterDescriptionClaudeGPTGemini
modelstringrequiredThe model id, as in the models list.ClaudeSupportedGPTSupportedGeminiSupported
messagesarrayrequiredThe conversation: messages with the roles system, user, assistant and tool. Content is text or a list of parts, images included.ClaudeSupportedGPTSupportedGeminiSupported
max_completion_tokensintegerThe maximum number of output tokens.ClaudeSupportedGPTIgnoredGeminiSupported
max_tokensintegerThe older name of max_completion_tokens; it works the same way.ClaudeSupportedGPTIgnoredGeminiSupported
temperaturenumberHow random the reply is.ClaudeSupportedGPTIgnoredGeminiSupported
top_pnumberSample only from the most likely tokens.ClaudeSupportedGPTIgnoredGeminiSupported
stopstring | arrayText that ends the reply. It does not reach the model in this format; with Claude and Gemini models use stop_sequences in Messages.ClaudeIgnoredGPTIgnoredGeminiIgnored
streambooleanSend the reply in parts as it is written. See Streaming.ClaudeSupportedGPTSupportedGeminiSupported
stream_optionsobjectinclude_usage adds the usage numbers to the last part. GPT models always send them.ClaudeSupportedGPTIgnoredGeminiSupported
toolsarrayFunctions the model can call. See Tool calling.ClaudeSupportedGPTSupportedGeminiSupported
tool_choicestring | objectauto, none, required or one named function.ClaudeSupportedGPTSupportedGeminiIgnored
parallel_tool_callsbooleanAllow or prevent several calls in one reply.ClaudeIgnoredGPTSupportedGeminiIgnored
response_formatobjectjson_schema or json_object for structured output. For Claude models use a tool with a schema in Messages.ClaudeIgnoredGPTSupportedGeminiIgnored
reasoning_effortstringHow hard the model thinks: low, medium or high.ClaudeSupportedGPTSupportedGeminiIgnored
nintegerNumber of replies. You always get one.ClaudeIgnoredGPTIgnoredGeminiIgnored
seedintegerAn attempt to repeat the same result.ClaudeIgnoredGPTIgnoredGeminiIgnored
presence_penaltynumberDiscourage returning to the same topics.ClaudeIgnoredGPTIgnoredGeminiIgnored
frequency_penaltynumberDiscourage repeating the same words.ClaudeIgnoredGPTIgnoredGeminiIgnored
logprobsbooleanToken probabilities in the reply. Not returned.ClaudeIgnoredGPTIgnoredGeminiIgnored
logit_biasobjectRaise or lower the odds of given tokens.ClaudeIgnoredGPTIgnoredGeminiIgnored
userstringAn id for the end user in your system.ClaudeIgnoredGPTIgnoredGeminiIgnored

Images in the request#

Put an image in the content list of a user message, as a data: URL in Base64 or a public https URL, next to the text. Every model in the list below with image input reads it. A large image makes the request heavier; see Limits.

Streaming#

With "stream": true the reply arrives as Server-Sent Events: each data: line holds a chat.completion.chunk with part of the text in choices[0].delta, and the stream ends with data: [DONE]. To get the usage numbers in the last chunk, add "stream_options": {"include_usage": true}; GPT models always send them. Details in Streaming.

Examples#

Streaming with usage#

curl -N https://api.5abeer.ai/v1/chat/completions \
  -H "Authorization: Bearer $KHABEER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-5",
    "messages": [
      {
        "role": "user",
        "content": "Write a product idea in one sentence."
      }
    ],
    "stream": true,
    "stream_options": {
      "include_usage": true
    }
  }'
Stream events
data: {"id":"chatcmpl_p8a01","object":"chat.completion.chunk","created":1790000000,"model":"claude-opus-5","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}

data: {"id":"chatcmpl_p8a01","object":"chat.completion.chunk","created":1790000000,"model":"claude-opus-5","choices":[{"index":0,"delta":{"content":"Lumen Notes: "},"finish_reason":null}]}

data: {"id":"chatcmpl_p8a01","object":"chat.completion.chunk","created":1790000000,"model":"claude-opus-5","choices":[{"index":0,"delta":{"content":"a notebook that turns voice memos "},"finish_reason":null}]}

data: {"id":"chatcmpl_p8a01","object":"chat.completion.chunk","created":1790000000,"model":"claude-opus-5","choices":[{"index":0,"delta":{"content":"into tidy to-do lists."},"finish_reason":null}]}

data: {"id":"chatcmpl_p8a01","object":"chat.completion.chunk","created":1790000000,"model":"claude-opus-5","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: {"id":"chatcmpl_p8a01","object":"chat.completion.chunk","created":1790000000,"model":"claude-opus-5","choices":[],"usage":{"prompt_tokens":21,"completion_tokens":18,"total_tokens":39}}

data: [DONE]

Calling a function#

curl https://api.5abeer.ai/v1/chat/completions \
  -H "Authorization: Bearer $KHABEER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-sol",
    "messages": [
      {
        "role": "user",
        "content": "What is the weather in Cairo?"
      }
    ],
    "tools": [
      {
        "type": "function",
        "function": {
          "name": "get_weather",
          "description": "Get the weather for a city",
          "parameters": {
            "type": "object",
            "properties": {
              "city": {
                "type": "string"
              }
            },
            "required": [
              "city"
            ]
          }
        }
      }
    ],
    "tool_choice": "auto",
    "parallel_tool_calls": false
  }'
Response shape
{
  "id": "chatcmpl_p8a01",
  "object": "chat.completion",
  "created": 1790000000,
  "model": "gpt-5.6-sol",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_p8a01",
            "type": "function",
            "function": {
              "name": "get_weather",
              "arguments": "{\"city\":\"Cairo\"}"
            }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ],
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 18,
    "total_tokens": 39
  }
}

JSON output with a schema#

curl https://api.5abeer.ai/v1/chat/completions \
  -H "Authorization: Bearer $KHABEER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-sol",
    "messages": [
      {
        "role": "user",
        "content": "Give me one product idea."
      }
    ],
    "response_format": {
      "type": "json_schema",
      "json_schema": {
        "name": "idea",
        "strict": true,
        "schema": {
          "type": "object",
          "properties": {
            "idea": {
              "type": "string"
            }
          },
          "required": [
            "idea"
          ],
          "additionalProperties": false
        }
      }
    },
    "reasoning_effort": "low"
  }'
Response shape
{
  "id": "chatcmpl_p8a01",
  "object": "chat.completion",
  "created": 1790000000,
  "model": "gpt-5.6-sol",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "{\"idea\":\"Lumen Notes: a notebook that turns voice memos into tidy to-do lists.\"}"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 18,
    "total_tokens": 39
  }
}

An image with the question#

curl https://api.5abeer.ai/v1/chat/completions \
  -H "Authorization: Bearer $KHABEER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-opus-5",
    "max_completion_tokens": 300,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What is in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
            }
          }
        ]
      }
    ]
  }'
Response shape
{
  "id": "chatcmpl_p8a01",
  "object": "chat.completion",
  "created": 1790000000,
  "model": "claude-opus-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Lumen Notes: a notebook that turns voice memos into tidy to-do lists."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 18,
    "total_tokens": 39
  }
}

Sampling settings#

curl https://api.5abeer.ai/v1/chat/completions \
  -H "Authorization: Bearer $KHABEER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3.1-pro",
    "messages": [
      {
        "role": "system",
        "content": "Answer in one sentence."
      },
      {
        "role": "user",
        "content": "Write a product idea."
      }
    ],
    "max_tokens": 300,
    "temperature": 0.4,
    "top_p": 0.9,
    "stop": [
      "END"
    ],
    "n": 1,
    "seed": 7,
    "presence_penalty": 0,
    "frequency_penalty": 0,
    "logprobs": false,
    "logit_bias": {},
    "user": "user-123"
  }'
Response shape
{
  "id": "chatcmpl_p8a01",
  "object": "chat.completion",
  "created": 1790000000,
  "model": "gemini-3.1-pro",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Lumen Notes: a notebook that turns voice memos into tidy to-do lists."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 18,
    "total_tokens": 39
  }
}

The request above was run on the local test stack on 2026-10-02; the reply shows the shape, and its text is an example.

Errors#

Errors from the key, balance and limit checks arrive before any model is called; the rest come from serving the request. The common ones:

The error shapes and the codes raised while serving the request, such as CONTEXT_LIMIT_EXCEEDED and MODEL_UNAVAILABLE, are in Limits and error codes. The full list is in Errors and fixes.

Limits#

  • A pay-as-you-go key is limited by your balance, and by the spend limit you set on it, if any.
  • Request size and context length are in Limits.

Models for this format#

per 1M tokens

Official price from the provider's page, checked October 19, 2026.

All models and prices