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.
API key in format: Bearer sk-xxxxxx
Body
Array of message objects representing the conversation Role of the message author: system, user, assistant, or tool
Name of the author (optional)
Tool calls made by the assistant (for assistant messages)
ID of the tool call this message is responding to (for tool messages)
Model ID to use for completion (blockchain hex address or name)
Sampling temperature between 0 and 2. Higher values make output more random.
Nucleus sampling parameter. Alternative to temperature.
Number of completions to generate
Whether to stream the response as server-sent events
Up to 4 sequences where the API will stop generating
Maximum number of tokens to generate
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far.
Number between -2.0 and 2.0. Positive values penalize new tokens based on their frequency in the text so far.
List of tools the model can call
Controls which tool is called by the model
Optional session ID to use. If not provided, uses the session associated with the API key.
Response
Unix timestamp of completion creation
Model used for the completion
Array of completion choices Reason the generation stopped: stop, length, tool_calls, or content_filter
Token usage statistics Number of tokens in the prompt
Number of tokens in the completion
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.