Chat Completions

The primary Serverless API: OpenAI-compatible chat completions with streaming, tools, structured outputs, and reasoning.

POST https://api.abhigya.ai/v1/chat/completions follows the OpenAI Chat Completions format, so OpenAI SDKs and compatible tools work by setting the base URL to https://api.abhigya.ai/v1.

Request

curl -sS https://api.abhigya.ai/v1/chat/completions \
-H "Authorization: Bearer $ABHIGYA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen/qwen2.5-7b-instruct",
"messages": [
{"role": "system", "content": "Answer in one sentence."},
{"role": "user", "content": "What is Abhigya Serverless?"}
],
"max_tokens": 1024
}'

Request fields

FieldNotes
modelRequired. A model ID from GET /v1/models.
messagesRequired. system, user, assistant, and tool messages.
max_tokensMaximum generated tokens, including reasoning tokens. max_completion_tokens is also accepted.
temperature, top_pSampling controls.
top_k, min_p, repetition_penaltyAdditional sampling controls.
stopStop sequences: at most 16, each at most 512 characters.
seedSampling seed.
nNumber of choices. Not every model supports n > 1.
streamStream server-sent events. See Streaming.
tools, tool_choiceFunction tools. See Tools.
response_formatJSON mode or JSON Schema. See Structured outputs.
reasoning_effortReasoning effort. See Reasoning.

Output length

Response

{
"id": "c3a7ac6de84a4e9eade77ab63a27a1ca",
"object": "chat.completion",
"created": 1790793243,
"model": "qwen/qwen2.5-7b-instruct",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Abhigya Serverless is pay-per-token access to hosted models.",
"reasoning_content": null,
"tool_calls": null
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 22,
"completion_tokens": 16,
"total_tokens": 38,
"prompt_tokens_details": {"cached_tokens": 0},
"completion_tokens_details": {"reasoning_tokens": 0}
}
}

finish_reason is stop, length, or tool_calls. See Usage and Billing for the usage fields.

Streaming

Set "stream": true to receive server-sent events. Each event is a data: line with a chat.completion.chunk object, followed by a blank line. The stream ends with data: [DONE].

curl -N -sS https://api.abhigya.ai/v1/chat/completions \
-H "Authorization: Bearer $ABHIGYA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen/qwen2.5-7b-instruct",
"messages": [{"role": "user", "content": "Count from 1 to 5."}],
"max_tokens": 256,
"stream": true
}'

Tools

Define tools with a JSON Schema for their parameters. parameters must be an object schema with "type": "object".

curl -sS https://api.abhigya.ai/v1/chat/completions \
-H "Authorization: Bearer $ABHIGYA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen/qwen2.5-7b-instruct",
"messages": [{"role": "user", "content": "What is the weather in Paris?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}],
"tool_choice": "auto",
"max_tokens": 1024
}'

When the model calls a tool, finish_reason is tool_calls and the message carries tool_calls. The arguments value is a JSON string. Run the tool, then send the assistant message and a tool message with the matching tool_call_id.

Structured outputs

Use response_format to constrain output to JSON. JSON mode returns a valid JSON object. JSON Schema constrains the output to your schema.

curl -sS https://api.abhigya.ai/v1/chat/completions \
-H "Authorization: Bearer $ABHIGYA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen/qwen2.5-7b-instruct",
"messages": [{"role": "user", "content": "Invent a fictional person."}],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "person",
"strict": true,
"schema": {
"type": "object",
"properties": {"name": {"type": "string"}, "age": {"type": "integer"}},
"required": ["name", "age"],
"additionalProperties": false
}
}
},
"max_tokens": 512
}'

The JSON is returned as a string in message.content. Parse it before use. Schema keywords that cannot be enforced during decoding are dropped from the constraint; validate the output if you rely on them.

Reasoning

Reasoning models can think before answering. Reasoning text is returned separately in message.reasoning_content, and reasoning tokens are reported in usage.completion_tokens_details.reasoning_tokens.

Control reasoning with reasoning_effort: none, low, medium, high, or max. An effort the model does not list runs at a nearby tier. An unknown value returns 400 with code unsupported_value.

curl -sS https://api.abhigya.ai/v1/chat/completions \
-H "Authorization: Bearer $ABHIGYA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek/deepseek-v4.1-flash",
"messages": [{"role": "user", "content": "Is 391 prime?"}],
"reasoning_effort": "high",
"max_tokens": 4096
}'

Reasoning tokens count toward max_tokens and bill as output tokens. If finish_reason is length with empty content, raise max_tokens or lower the effort.

Zero Data Retention

Zero Data Retention is enabled by default. No header is needed. See Zero Data Retention.