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.
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.
https:/ / api.5abeer.ai/ v1/ chat/ completionsAuthentication#
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:
https://api.5abeer.ai/v1Authorization: Bearer <KEY>https://api.5abeer.aix-api-key: <KEY>https://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."}]}'{
"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.
messagesarrayrequiredThe conversation: messages with the roles system, user, assistant and tool. Content is text or a list of parts, images included.ClaudeSupportedGPTSupportedGeminiSupportedmax_completion_tokensintegerThe maximum number of output tokens.ClaudeSupportedGPTIgnoredGeminiSupportedmax_tokensintegerThe older name of max_completion_tokens; it works the same way.ClaudeSupportedGPTIgnoredGeminiSupportedtemperaturenumberHow random the reply is.ClaudeSupportedGPTIgnoredGeminiSupportedtop_pnumberSample only from the most likely tokens.ClaudeSupportedGPTIgnoredGeminiSupportedstopstring | arrayText that ends the reply. It does not reach the model in this format; with Claude and Gemini models use stop_sequences in Messages.ClaudeIgnoredGPTIgnoredGeminiIgnoredstreambooleanSend the reply in parts as it is written. See Streaming.ClaudeSupportedGPTSupportedGeminiSupportedstream_optionsobjectinclude_usage adds the usage numbers to the last part. GPT models always send them.ClaudeSupportedGPTIgnoredGeminiSupportedtool_choicestring | objectauto, none, required or one named function.ClaudeSupportedGPTSupportedGeminiIgnoredparallel_tool_callsbooleanAllow or prevent several calls in one reply.ClaudeIgnoredGPTSupportedGeminiIgnoredresponse_formatobjectjson_schema or json_object for structured output. For Claude models use a tool with a schema in Messages.ClaudeIgnoredGPTSupportedGeminiIgnoredreasoning_effortstringHow hard the model thinks: low, medium or high.ClaudeSupportedGPTSupportedGeminiIgnorednintegerNumber of replies. You always get one.ClaudeIgnoredGPTIgnoredGeminiIgnoredseedintegerAn attempt to repeat the same result.ClaudeIgnoredGPTIgnoredGeminiIgnoredpresence_penaltynumberDiscourage returning to the same topics.ClaudeIgnoredGPTIgnoredGeminiIgnoredfrequency_penaltynumberDiscourage repeating the same words.ClaudeIgnoredGPTIgnoredGeminiIgnoredlogprobsbooleanToken probabilities in the reply. Not returned.ClaudeIgnoredGPTIgnoredGeminiIgnoredlogit_biasobjectRaise or lower the odds of given tokens.ClaudeIgnoredGPTIgnoredGeminiIgnoreduserstringAn id for the end user in your system.ClaudeIgnoredGPTIgnoredGeminiIgnoredImages 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
}
}'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
}'{
"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"
}'{
"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=="
}
}
]
}
]
}'{
"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"
}'{
"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:
invalid_request_error: the request is missing something or has an invalid value, such as a missingmodel.INVALID_API_KEY: the key is wrong.MODEL_PLATFORM_NOT_ALLOWED: the key belongs to another provider than the model.INSUFFICIENT_BALANCE: your balance doesn't cover the request.USAGE_LIMIT_EXCEEDED: the subscription reached its 5-hour or weekly limit.RATE_LIMITED: too many requests in a short time.
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#
Claude Sonnet 5.5DefaultInput$0.60Output$3Context1M
Claude Opus 5.5Input$1.20Output$6Context1M
GPT-6.1 SolInput$0.60Output$3Context922K
Gemini 4 ArgonInput$0.60Output$3Context—Claude Fable 5.1Input$3Output$15Context—
Claude Fable 5Input$3Output$15Context1M
Official price from the provider's page, checked October 19, 2026.
All models and pricesWas this page helpful?