Chat Completions
The Chat Completions endpoint is the primary way to interact with ORVEXA models. It is fully compatible with the OpenAI Chat Completions API.
POST
/v1/chat/completionsOpenAI-compatible chat endpointRequest Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Required | The ID of the model to use (e.g., deepseek-chat). |
messages | array | Required | An array of message objects containing the conversation history. Each object has a role (system, user, or assistant) and content. |
temperature | number | Optional | Sampling temperature between 0 and 2. Higher values make output more random; lower values make it more focused. Default is 1. |
max_tokens | integer | Optional | The maximum number of tokens to generate in the response. |
stream | boolean | Optional | If set to true, partial message deltas are sent as server-sent events (SSE) as they become available. |
top_p | number | Optional | Nucleus sampling parameter. The model considers results of tokens with top_p probability mass. Default is 1. |
frequency_penalty | number | Optional | Number between -2.0 and 2.0. Positive values penalize new tokens based on their frequency in the text so far. |
presence_penalty | number | Optional | Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far. |
stop | string | array | Optional | Up to 4 sequences where the API will stop generating further tokens. |
Code Examples
bash
curl https://api.orvexaproject.com/v1/chat/completions \
-H "Authorization: Bearer nx-sk-dcfab6de7407c3c5f74fb627" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Write a haiku about coding."}
],
"temperature": 0.7,
"max_tokens": 150
}'Response Format
For non-streaming requests, the API returns a complete JSON object once the model finishes generating.
Non-streaming responsejson
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1718000000,
"model": "deepseek-chat",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Keys click and tap bright,\nLogic flows through silent lines,\nBugs flee into night."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 17,
"total_tokens": 37
}
}Streaming Response
When stream is set to true, the response is sent as server-sent events (SSE). Each chunk contains a delta object with the incremental content. The stream ends with a [DONE] message.
Streaming chunkstext
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Keys"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" click"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]ORVEXA-Specific Headers
ORVEXA extends the OpenAI API with additional HTTP headers for cost control, caching, and multi-model fusion.
X-Orvexa-Max-CostSets a maximum cost limit in USD for the request. If the estimated cost exceeds this value, the request is rejected with a 402 error.X-Response-CacheWhen set to true, identical requests within the cache TTL return cached responses, reducing latency and cost.X-Prompt-CacheEnables automatic prompt caching. Repeated prefixes in messages are cached to reduce input token costs.X-Orvexa-FusionEnables multi-model fusion mode. See the Fusion documentation for details.Request with custom headersbash
curl https://api.orvexaproject.com/v1/chat/completions \
-H "Authorization: Bearer nx-sk-dcfab6de7407c3c5f74fb627" \
-H "Content-Type: application/json" \
-H "X-Orvexa-Max-Cost: 0.05" \
-H "X-Response-Cache: true" \
-H "X-Prompt-Cache: true" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Hello"}]
}'