Skip to main content
POST
Chat Completions
Create a chat completion with automatic session creation if enabled. Supports both streaming and non-streaming responses based on the stream parameter. Tool calling is supported but may work better with streaming enabled.

Headers

string
required
API key in format: Bearer sk-xxxxxx

Body

array
required
Array of message objects representing the conversation
string
Model ID to use for completion (blockchain hex address or name)
number
default:1
Sampling temperature between 0 and 2. Higher values make output more random.
number
default:1
Nucleus sampling parameter. Alternative to temperature.
integer
default:1
Number of completions to generate
boolean
default:false
Whether to stream the response as server-sent events
string | array
Up to 4 sequences where the API will stop generating
integer
Maximum number of tokens to generate
number
default:0
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far.
number
default:0
Number between -2.0 and 2.0. Positive values penalize new tokens based on their frequency in the text so far.
array
List of tools the model can call
string | object
Controls which tool is called by the model
string
Optional session ID to use. If not provided, uses the session associated with the API key.

Response

string
Unique completion ID
string
Always “chat.completion”
integer
Unix timestamp of completion creation
string
Model used for the completion
array
Array of completion choices
object
Token usage statistics
The API is fully compatible with the OpenAI SDK. Simply change the base_url to point to the Morpheus Gateway.
Streaming responses return server-sent events. Set stream: true in your request to enable streaming.