Skip to main content
POST
/
chat
/
completions
curl -X POST https://api.blackbox.ai/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "blackboxai/openai/gpt-4",
    "messages": [
        {
            "role": "user",
            "content": "What is the capital of France?"
        }
    ],
    "temperature": 0.7,
    "max_tokens": 256,
    "stream": false
}'
{
  "id":"gen-...",
  "created":1757140020,
  "model":"openai/gpt-4",
  "object":"chat.completion",
  "system_fingerprint":"None",
  "choices":[
    {
      "finish_reason":"stop",
      "index":0,
      "message":{
        "content":"The capital of France is Paris.",
        "role":"assistant",
        "tool_calls":"None",
        "function_call":"None"
      },
      "provider_specific_fields":{
        "native_finish_reason":"stop"
      }
    }
  ],
  "usage":{
    "completion_tokens":7,
    "prompt_tokens":14,
    "total_tokens":21,
    "completion_tokens_details":{
      "accepted_prediction_tokens":"None",
      "audio_tokens":"None",
      "reasoning_tokens":0,
      "rejected_prediction_tokens":"None"
    },
    "prompt_tokens_details":{
      "audio_tokens":0,
      "cached_tokens":0
    }
  },
  "provider":"OpenAI"
}

Headers

Authorization
string
required
API Key of the from Bearer <api_key>, you can get it from here.

Request

model
string
required
The model ID to use. See the Chat Models page
messages
array
required
Array of message objects containing the conversation history.
models
array
Alternate list of models for routing overrides.
provider
object
Preferences for provider routing.
transforms
array
List of prompt transforms (OpenRouter-only).
stream
boolean
Enable streaming of results via Server-Sent Events.
max_tokens
integer
Maximum number of tokens to generate (range: [1, context_length)).
temperature
number
Sampling temperature (range: [0, 2]).
seed
integer
Seed for deterministic outputs.
top_p
number
Top-p sampling value (range: (0, 1]).
top_k
integer
Top-k sampling value (range: [1, Infinity)).
frequency_penalty
number
Frequency penalty (range: [-2, 2]).
presence_penalty
number
Presence penalty (range: [-2, 2]).
repetition_penalty
number
Repetition penalty (range: (0, 2]).
logit_bias
object
Mapping of token IDs to bias values.
top_logprobs
integer
Number of top log probabilities to return.
min_p
number
Minimum probability threshold (range: [0, 1]).
top_a
number
Alternate top sampling parameter (range: [0, 1]).
stop
array
Stop sequences - generation will stop if any of these strings are encountered.
tools
array
Tool definitions following OpenAI’s tool calling format.
tool_choice
string | object
Controls which (if any) tool is called by the model.
  • none - Model will not call any tool
  • auto - Model can pick between generating a message or calling tools
  • required - Model must call one or more tools
  • Or specify a particular tool via {"type": "function", "function": {"name": "function_name"}}
response_format
object
Enforce structured output format.
user
string
A stable identifier for your end-users. Used to help detect and prevent abuse.

Response

id
string
Unique identifier for the chat completion.
created
integer
Unix timestamp when the completion was created.
model
string
The model used for the completion.
object
string
Object type, always chat.completion or chat.completion.chunk for streaming.
system_fingerprint
string | null
System fingerprint for the model configuration.
choices
array
Array of completion choices.
usage
object
Token usage information.
provider
string
The provider that served the request.
curl -X POST https://api.blackbox.ai/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "blackboxai/openai/gpt-4",
    "messages": [
        {
            "role": "user",
            "content": "What is the capital of France?"
        }
    ],
    "temperature": 0.7,
    "max_tokens": 256,
    "stream": false
}'
{
  "id":"gen-...",
  "created":1757140020,
  "model":"openai/gpt-4",
  "object":"chat.completion",
  "system_fingerprint":"None",
  "choices":[
    {
      "finish_reason":"stop",
      "index":0,
      "message":{
        "content":"The capital of France is Paris.",
        "role":"assistant",
        "tool_calls":"None",
        "function_call":"None"
      },
      "provider_specific_fields":{
        "native_finish_reason":"stop"
      }
    }
  ],
  "usage":{
    "completion_tokens":7,
    "prompt_tokens":14,
    "total_tokens":21,
    "completion_tokens_details":{
      "accepted_prediction_tokens":"None",
      "audio_tokens":"None",
      "reasoning_tokens":0,
      "rejected_prediction_tokens":"None"
    },
    "prompt_tokens_details":{
      "audio_tokens":0,
      "cached_tokens":0
    }
  },
  "provider":"OpenAI"
}
I