BazaarLinkBazaarLink
Sign in
DocsAPI ReferenceSDK ReferenceAgentic UsageAI Skills
Chat

Create a chat

Requests a model response for the given chat conversation. Supports both streaming and non-streaming modes, with one OpenAI-compatible request/response shape across every model and provider.

POST/api/v1/chat/completions

Authorizations

Authorizationrequired
string · header

API key as bearer token in the Authorization header.

Body

modelrequired
string

The model to use, provider-qualified, e.g. "openai/gpt-4.1". Short ids from common model families (e.g. "gpt-4o") are automatically resolved to the full canonical id ("openai/gpt-4o"); values already in canonical form pass through unchanged. An unrecognized short id is not force-rewritten — model resolution surfaces a clear model-not-found error instead.

minLength: 1
Example: "openai/gpt-4.1"
messagesrequired
Message[]

Array of conversation messages, at least one. Each has a role (system/user/assistant/tool) and content.

minLength: 1
models
string[]

Fallback model list — tried in order, only used once the primary model's own candidate group is exhausted.

stream
boolean

true streams the response as SSE; omitted or false returns a single JSON response.

temperature
number

Sampling temperature — higher is more random, lower is more deterministic.

0–2
max_tokens
integer

Maximum number of tokens the response may generate.

max_completion_tokens
integer

Alias of max_tokens with identical semantics.

top_p
number

Nucleus sampling threshold.

0–1
top_k
integer

Limits sampling to the K highest-probability tokens.

frequency_penalty
number

Penalizes tokens based on how often they've already appeared.

-2.0–2.0
presence_penalty
number

Penalizes tokens based on whether they've appeared at all, regardless of count.

-2.0–2.0
repetition_penalty
number

Repetition penalty coefficient — a separate mechanism from frequency/presence penalty.

min_p
number

Minimum probability threshold relative to the most likely token.

0–1
top_a
number

Another dynamic-cutoff sampling mechanism, scaling the threshold by the square of the top probability.

seed
integer

Deterministic sampling seed; not all providers guarantee reproducibility.

n
integer

Number of completions to generate.

stop
string | string[]

Sequences where generation stops, up to 4.

tools
Tool[]

List of tool/function definitions the model may call.

tool_choice
string | object

Controls whether/how the model is forced to call a tool.

parallel_tool_calls
boolean

Whether to allow parallel tool calls when tools are provided. Default true. OpenAI-family models only — silently stripped when the target model isn't OpenAI's own, not an error.

response_format
object

Constrains the output format, e.g. {type:"json_object"} or {type:"json_schema"} with a JSON Schema.

logit_bias
object

Maps token IDs to bias values [-100, 100] added before sampling. OpenAI-family models only — silently stripped when the target model isn't OpenAI's own, not an error.

logprobs
boolean

Return log probabilities of each output token. OpenAI-family models only — silently stripped when the target model isn't OpenAI's own, not an error.

top_logprobs
integer

Number of most-likely tokens to return per position (requires logprobs: true). OpenAI-family models only — silently stripped when the target model isn't OpenAI's own, not an error.

0–20
user
string

End-user identifier for monitoring and abuse detection. Has no effect on billing. OpenAI-family models only — silently stripped when the target model isn't OpenAI's own, not an error.

reasoning
object

Reasoning-model thinking control object (e.g. {effort, max_tokens}).

reasoning_effort
string

Flat shorthand for reasoning.effort.

lowmediumhigh
image_config
object

Image generation/edit options (used when modalities includes image).

modalities
string[]

Requested output modalities. Including image routes through the image-generation dispatch path.

textimage
plugins
object[]

Array of plugins (e.g. {id:"web"} to enable web search). Supported only on some model routes, no effect elsewhere; the :online model variant auto-injects {id:"web"}, likewise only on supporting routes.

POST /api/v1/chat/completions
curl https://bazaarlink.ai/api/v1/chat/completions \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1",
    "messages": [{"role": "user", "content": "Explain quantum computing in one paragraph."}]
  }'
Response examples

Success. BazaarLink normalizes exactly two fields — model, and the removal of a provider field — and forwards the rest of the upstream response as-is, including fields like native_finish_reason, system_fingerprint, and reasoning that are only present when that specific provider populates them. usage.cost is the exception — always BazaarLink's own settled amount, not a value relayed from upstream.

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1740000000,
  "model": "openai/gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Quantum computing leverages quantum mechanics..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 28,
    "completion_tokens": 74,
    "total_tokens": 102,
    "cost": 0.000648
  }
}
Support
Support
Hi! How can we help you?
Send a message and we'll get back to you soon.
Create a chat — BazaarLink API