Chat Completions
POST /v1/chat/completions
Create a chat completion. This endpoint is OpenAI-compatible and supports streaming, tool calling, and JSON mode.
Endpoint
POST https://api.leaper.one/v1/chat/completionsParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model ID. Supported: "auto", "gpt-5-nano" |
| messages | array | Yes | Array of message objects with "role" (system/user/assistant) and "content" |
| stream | boolean | No | If true, partial message deltas sent as SSE. Default: false |
| temperature | number | No | Sampling temperature 0-2. Default: 0.7 |
| top_p | number | No | Nucleus sampling. Default: 1 |
| max_tokens | integer | No | Maximum tokens to generate |
| stop | string | array | No | Up to 4 stop sequences |
| tools | array | No | List of tool definitions the model may call |
| tool_choice | string | object | No | "none", "auto", or specify a function |
| response_format | object | No | { "type": "json_object" } for JSON mode |
Request
curl -X POST https://api.leaper.one/v1/chat/completions \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "What is LEAPERone?" }
],
"temperature": 0.7,
"max_tokens": 256
}'Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1700000000,
"model": "gpt-5-nano",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "LEAPERone is a unified AI API gateway that gives you access to multiple AI models through a single API key."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 22,
"total_tokens": 47
}
}Notes
"auto"routes togpt-5-nanoby default.- When
streamistrue, partial deltas are sent as Server-Sent Events (SSE). The stream terminates with a[DONE]message. - Billing is calculated per token based on the resolved model.