Chat Completions

Send a conversation as messages and receive an assistant message.

POST/openai/v1/chat/completions

Create a completion

Set BUILD_OPENAI_KEY in your backend environment. Use gpt-5.6-luna as the model. Include previous user and assistant messages to continue a conversation.

curl · whole response

curl "https://proxy.litechat.ai/openai/v1/chat/completions" \
  -H "Authorization: Bearer $BUILD_OPENAI_KEY" \
  -H "Content-Type: application/json" \
  --data '{
    "model": "gpt-5.6-luna",
    "messages": [{"role": "user", "content": "Say hello in one sentence."}],
    "max_tokens": 128,
    "reasoning_effort": "none"
  }'

Read the answer

Read text from choices[0].message.content. Inspect finish_reason: stop indicates a normal finish, length indicates the token limit, and tool_calls hands control to your backend.

Illustrative whole response · selected fields

{
  "id": "chatcmpl_example",
  "object": "chat.completion",
  "model": "gpt-5.6-luna",
  "choices": [{
    "index": 0,
    "message": {"role": "assistant", "content": "Hello! How can I help?"},
    "finish_reason": "stop"
  }],
  "usage": {"prompt_tokens": 12, "completion_tokens": 8, "total_tokens": 20}
}

IDs, text, and token counts are examples. Tool responses can contain message.tool_calls instead of answer text.

Common parameters

messages
A conversation array with roles and content. Use system for instructions, user for input, and assistant for earlier replies.
max_tokens and reasoning_effort
Set an output limit. The example disables reasoning with none; effort controls are also available for reasoning. Preserve returned reasoning and tool history for later turns.
tools
Declare functions your backend can execute. Preserve each call ID when returning its result. Use automatic tool choice when reasoning is enabled.
response_format
Text, JSON object, and JSON Schema output are supported. Schema output is validated in full before it is sent. Use local schema references; remote references are rejected. Schema conversion cannot be combined with stop sequences, log probabilities, or frequency/presence penalties.

Streaming

Add "stream": true to the request body above and pass --no-buffer to curl. The SSE chunks use choices[].delta; text is in delta.content when present. Optional stream_options.include_usage adds usage chunks with empty choices. Check the finish reason and [DONE]; an error or interrupted stream is not success.

See the OpenAI Chat Completions streaming reference.

← Getting startedBack to top ↑