LEAPERone Docs

Chat Completions

Send messages and get AI responses.

The Chat Completions endpoint is fully OpenAI-compatible. Point any existing OpenAI SDK or HTTP client at LEAPERone and it works out of the box.

Basic Request

POST /v1/chat/completions
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": "user", "content": "Explain quantum computing in one paragraph."}
    ]
  }'
Response
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Quantum computing uses qubits..."
      },
      "finish_reason": "stop"
    }
  ]
}

Setting model to "auto" routes your request to the best available model automatically. You can also specify a model explicitly (e.g., "gpt-4o", "claude-sonnet-4-20250514").

Streaming

Set stream: true to receive results as Server-Sent Events (SSE). Tokens are delivered incrementally as they are generated.

Streaming 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",
    "stream": true,
    "messages": [
      {"role": "user", "content": "Write a haiku about APIs."}
    ]
  }'

Each SSE event contains a data: line with a JSON chunk:

data: {"id":"chatcmpl-abc123","choices":[{"delta":{"content":"Endpoints"},"index":0}]}

data: {"id":"chatcmpl-abc123","choices":[{"delta":{"content":" await"},"index":0}]}

data: [DONE]

Tools / Function Calling

You can pass a tools array to let the model call functions you define. The model will return a tool_calls response when it decides a function should be invoked. This follows the same format as the OpenAI function calling API.

Tools Parameter (abbreviated)
{
  "model": "auto",
  "messages": [{"role": "user", "content": "What's the weather in Tokyo?"}],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get current weather for a city",
        "parameters": {
          "type": "object",
          "properties": {
            "city": {"type": "string"}
          },
          "required": ["city"]
        }
      }
    }
  ]
}

For the complete parameter list and response schema, see the API Reference.