Chat Completions

Generate model responses for a conversation. Drop-in compatible with OpenAI's Chat Completions API.

Endpoint

http
POST https://www.linguachats.ai/v1/chat/completions

Request body

json
{
  "model": "lyra",
  "messages": [
    {"role": "user", "content": "Write a short story opening."}
  ],
  "stream": false,
  "max_tokens": 1024,
  "temperature": 0.8
}

model (required) — a LinguaChats model slug, e.g. lyra, zenith, sage. See the Models page for the full catalog.

messages (required) — the conversation so far, as system, user, and assistant messages. Each LinguaChats model applies its own specialized system prompt before your messages; any system message you send is appended after ours as additional guidance.

stream (optional) — set true to receive server-sent events.

max_tokens (optional) — capped at 8192 per request.

Also supported: temperature, top_p, stop, frequency_penalty, presence_penalty.

Response

json
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1720000000,
  "model": "lyra",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "The lighthouse keeper found the letter on a Tuesday..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 42,
    "completion_tokens": 118,
    "total_tokens": 160
  }
}

Streaming

With stream: true, the response is a standard OpenAI-style SSE stream of chat.completion.chunk events, terminated by data: [DONE]. The official OpenAI SDKs handle this out of the box — just set the base URL to https://www.linguachats.ai/v1:

curl https://www.linguachats.ai/v1/chat/completions \
  -H "Authorization: Bearer $LINGUACHATS_API_KEY" \
  -H "Content-Type: application/json" \
  -N \
  -d '{
    "model": "lyra",
    "messages": [
      {
        "role": "user",
        "content": "Tell me a short story about a lighthouse."
      }
    ],
    "stream": true
  }'

Credits are charged when the stream ends (or is cancelled), based on the tokens actually generated.

List models

GET https://www.linguachats.ai/v1/models returns the available model slugs in OpenAI list format.