Skip to main content

Chat Completions

POST /api/v1/chat/completions
Not all models support every option beyond the basic request. Check the Model Library for model-specific compatibility. Open Model Library.

Base URL

https://app.eigenai.com

Authentication

Send your API key in the Authorization header as a Bearer token.
Authorization: Bearer YOUR_API_KEY

Parameters

Common

NameTypeRequiredDescription
modelstringRequiredThe model ID to use. Find supported models in the Model Library.
messagesarrayRequiredConversation history as an array of { role, content } items.

Conditional

These options are not supported by every model. Use the Model Library to confirm compatibility.

Generation Controls

Common tuning knobs for output length and randomness (availability varies by model).
NameTypeRequiredDescription
temperaturenumberOptionalControls randomness/creativity. Higher values produce more varied outputs.
max_tokensnumberOptionalMaximum number of tokens to generate in the response.
top_pnumberOptionalNucleus sampling. Limits token selection to the smallest set with cumulative probability top_p.
top_knumberOptionalTop-k sampling. Limits token selection to the top k candidates.
min_pnumberOptionalMinimum probability threshold sampling (if supported).
repetition_penaltynumberOptionalPenalizes repeating tokens (if supported).

Streaming

Receive partial outputs incrementally.
NameTypeRequiredDescription
streambooleanOptionalSet to true to stream output via server-sent events (SSE).

Vision Input (Multi-part Message Content)

Some models accept mixed text + image inputs by using an array for content on a message.
NameTypeRequiredDescription
messages[].contentstring|arrayOptionalFor vision requests, content can be an array of parts like { type: "text" } and { type: "image_url" }.

Examples

Basic request

Send a list of messages and receive a single response.
# Select a model in the Model Library: https://app.eigenai.com/model-library

curl -X POST https://app.eigenai.com/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain quantum computing in simple terms."}
    ],
    "temperature": 0.7,
    "max_tokens": 2000,
    "stream": false
  }'

Streaming (SSE)

Stream partial output tokens as SSE events.
# Select a model in the Model Library: https://app.eigenai.com/model-library

# Streaming uses Server-Sent Events (SSE). This prints raw SSE frames.
curl -N -X POST https://app.eigenai.com/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL",
    "messages": [
      {"role": "user", "content": "Write a 1-paragraph product update."}
    ],
    "stream": true
  }'

Vision input (text + image)

Send multi-part message content with text and image URLs.
# Select a model in the Model Library: https://app.eigenai.com/model-library

curl -X POST https://app.eigenai.com/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL",
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "Describe the image."},
          {"type": "image_url", "image_url": {"url": "https://example.com/image.png"}}
        ]
      }
    ],
    "max_tokens": 500,
    "stream": false
  }'