Chat Completions

Generate a model response for a conversation. This is the core endpoint — it works identically to OpenAI's chat completions API.

Endpoint

POST https://sovereigneg.com/v1/chat/completions

Request body

ParameterTypeRequiredDescription
modelstringYesModel ID from GET /v1/models or the Model Library
messagesarrayYesConversation messages (see below)
temperaturefloatNoSampling temperature (0.0–2.0). Default: 1.0
max_tokensintegerNoMax tokens to generate. Default: model-dependent
top_pfloatNoNucleus sampling (0.0–1.0). Default: 1.0
streambooleanNoStream response via SSE. Default: false
stopstring/arrayNoStop sequences
frequency_penaltyfloatNoFrequency penalty (-2.0 to 2.0). Default: 0.0
presence_penaltyfloatNoPresence penalty (-2.0 to 2.0). Default: 0.0

Message roles

RolePurpose
systemSets the behavior of the assistant
userThe human's input
assistantThe model's previous response (for multi-turn)

Example request

from openai import OpenAI
 
client = OpenAI(
    api_key="sk-...",
    base_url="https://sovereigneg.com/v1"
)
 
response = client.chat.completions.create(
    model="...",
    messages=[
        {"role": "system", "content": "You are a concise technical writer."},
        {"role": "user", "content": "Explain how transformers work in 3 sentences."}
    ],
    temperature=0.7,
    max_tokens=256
)
 
print(response.choices[0].message.content)

Response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1711000000,
  "model": "...",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Transformers use self-attention mechanisms..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 28,
    "completion_tokens": 65,
    "total_tokens": 93
  }
}

Streaming

Set stream: true to receive tokens as server-sent events. See Streaming for details.

Multi-turn conversation

Pass the full conversation history in the messages array:

response = client.chat.completions.create(
    model="...",
    messages=[
        {"role": "system", "content": "You are a helpful math tutor."},
        {"role": "user", "content": "What is 15% of 200?"},
        {"role": "assistant", "content": "15% of 200 is 30."},
        {"role": "user", "content": "And 20% of the same number?"}
    ]
)