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
Request fields
| Field | Notes |
|---|---|
model | Required. A model ID from GET /v1/models. |
messages | Required. system, user, assistant, and tool messages. |
max_tokens | Maximum generated tokens, including reasoning tokens. max_completion_tokens is also accepted. |
temperature, top_p | Sampling controls. |
top_k, min_p, repetition_penalty | Additional sampling controls. |
stop | Stop sequences: at most 16, each at most 512 characters. |
seed | Sampling seed. |
n | Number of choices. Not every model supports n > 1. |
stream | Stream server-sent events. See Streaming. |
tools, tool_choice | Function tools. See Tools. |
response_format | JSON mode or JSON Schema. See Structured outputs. |
reasoning_effort | Reasoning effort. See Reasoning. |
Output length
max_tokensbounds generated tokens, including reasoning tokens.- When you omit
max_tokens, a default applies: the model's output cap, otherwise 65,536 tokens or half the context window, whichever is smaller. - A
max_tokensabove the model's cap is lowered to that cap. - If the prompt plus
max_tokensdoes not fit the context window, the request returns400with codecontext_length_exceeded.
Response
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].
- The first chunk sets
delta.role. - Text arrives in
delta.content. Reasoning text arrives indelta.reasoning_content. - A non-null
finish_reasonends the choice. - A final chunk with an empty
choicesarray carriesusage.
Tools
Define tools with a JSON Schema for their parameters. parameters must be an object schema with "type": "object".
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.
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.
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.