Skip to content

Chat Completions

POST /v1/chat/completions

Creates a chat completion. This is the primary endpoint for generating AI responses.

Request

Headers

Header Required Description
x-api-key Yes Your API key
Content-Type Yes application/json

Body Parameters

Parameter Type Required Description
model string Yes Model ID to use (see Models)
messages array Yes List of messages in the conversation
temperature float No Sampling temperature, 0.0 to 2.0
max_tokens integer No Maximum tokens to generate
top_p float No Nucleus sampling parameter, 0.0 to 1.0
stream boolean No Not yet implemented — coming in v2.0. Stream the response via Server-Sent Events (default: false)
stop string or array No Stop sequence(s) to end generation

Message Object

Field Type Required Description
role string Yes One of system, user, or assistant
content string Yes The message content

Response

Non-Streaming

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "claude-3-7-sonnet",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 12,
    "total_tokens": 22
  }
}

Streaming

Not yet implemented. Streaming support (stream: true) is coming in v2.0. Requests with stream: true will return an error.

Finish Reasons

Value Meaning
stop Natural end of response or stop sequence hit
length Hit max_tokens limit
content_filter Content was filtered by the provider's safety system

Examples

Basic Completion

curl -X POST https://api.consus.io/v1/chat/completions \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-7-sonnet",
    "messages": [
      {"role": "user", "content": "What is FedRAMP?"}
    ]
  }'

With System Prompt and Parameters

curl -X POST https://api.consus.io/v1/chat/completions \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-4-5-sonnet",
    "messages": [
      {"role": "system", "content": "You are a helpful government compliance assistant."},
      {"role": "user", "content": "Summarize CMMC Level 2 requirements."}
    ],
    "temperature": 0.3,
    "max_tokens": 2048
  }'

Multi-Turn Conversation

curl -X POST https://api.consus.io/v1/chat/completions \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-7-sonnet",
    "messages": [
      {"role": "user", "content": "What is an ATO?"},
      {"role": "assistant", "content": "An ATO (Authority to Operate) is a formal authorization..."},
      {"role": "user", "content": "How long does it typically take to get one?"}
    ]
  }'

Streaming

Not yet implemented. Streaming support is coming in v2.0.