BazaarLinkBazaarLink
Sign in
DocsAPI ReferenceSDK ReferenceAgentic UsageAI Skills
Chat

Create a chat

BazaarLink returns a standardized response and removes upstream-specific fields. usage.cost is the USD amount charged to the customer for this request. Use the opaque BazaarLink request id from the response id or x-request-id with GET /v1/generation; non-streaming responses also return it in x-generation-id. Stats may take a few seconds after completion; retry a 404 briefly. Long non-streaming Chat, Messages, and Responses requests (about 12 seconds or longer) may start with whitespace keep-alive padding before the JSON body. Standard JSON parsers accept leading whitespace. Audio chat uses this endpoint; request audio output with modalities:["text","audio"] and audio:{voice,format}. GET /v1/models?output_modalities=audio filters audio output only, not all audio-input models; audio-input models producing text remain in the text list. Capability metadata alone does not guarantee an available route; select a listed model and its supported parameters. Audio-only output, TTS, STT, and other non-token generation modes are outside this contract.

POST/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-4o". GET /v1/models lists ids such as "claude-sonnet-4.6" and canonical aliases such as "anthropic/claude-sonnet-4.6". Requests accept either form; use a listed id or alias.

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

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

minLength: 1
content
string | ContentPart[]

Put audio input in messages[].content[]: {"type":"input_audio","input_audio":{"data":"<raw base64>","format":"wav"}}. Use raw base64, not a data URI; formats depend on the model. Do not use top-level input_audio: it has no dedicated validation or credit-reservation contract.

Example: [{"type":"input_audio","input_audio":{"data":"<raw base64>","format":"wav"}}]
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. Audio streams return data (base64 audio) and transcript fragments in choices[].delta.audio; non-streaming responses use choices[].message.audio. The model may also provide id and expires_at. Accumulate fragments and decode using audio.format; streaming formats depend on the model.

temperature
number

Sampling temperature — higher is more random, lower is more deterministic. Sampling values are forwarded without range validation; the model may clamp or ignore values outside its supported range.

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.

top_k
integer

Limits sampling to the K highest-probability tokens.

frequency_penalty
number

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

presence_penalty
number

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

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.

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
include_reasoning
boolean

true returns the thinking text in message.reasoning (delta.reasoning when streaming); false turns thinking off for the models that think by default (see the reasoning section), so no thinking is billed. Without reasoning_effort, reasoning or thinking, only those models think and return it by default; other models return it only when asked.

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. Audio chat uses ["text","audio"] with an audio object and requires a model supporting text and audio output.

textimageaudio
Example: ["text","audio"]
audio
object

Audio output options with modalities:["text","audio"]. Supported voice and format values depend on the model.

Example: {"voice":"alloy","format":"wav"}
voice
string

A voice supported by the model, for example alloy.

Example: "alloy"
format
string

An output format supported by the model, for example wav; streaming commonly uses pcm16, subject to model support.

Example: "wav"
plugins
object[]

Array of plugins (e.g. {id:"web"} to enable web search). Supported only on some model routes, with no effect elsewhere; :online enables web search on supported routes. Web search requested through plugins, :online, or web_search_options may incur an upstream add-on charge on the key used: BazaarLink's platform key or your BYOK key.

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

Success. BazaarLink returns only fields from its public response allowlist, such as its own response ID, model, choices, and usage. The model field follows BazaarLink's public reporting rule: after alias resolution it may retain the name you requested, while auto-routed requests show the model that served them. The provider field and other upstream-only metadata are removed. usage.cost is always BazaarLink's settled amount.

{
  "id": "85e6f35c71a31f19-SJC",
  "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