Create a chat completion
Start a turn with a Manyfold agent through the OpenAI-compatible Chat Completions shape.
POST
/api/v1/chat/completions - Auth
- Bearer API token with chat.completions or api.full.
- Quota
- Counts against the monthly API request quota.
Parameters
| Parameters | Required | Description |
|---|---|---|
| model | Required | Manyfold agent id, for example agt_... |
| messages | Required | system/developer/user/assistant messages. A user message may include image_url and file content parts. |
| stream | Optional | Set true for Server-Sent Events. |
| metadata.session_id | Optional | Continue an existing Manyfold session returned by a previous turn. |
| stream_options.include_usage | Optional | When true, streaming can include a final usage chunk if usage is available. |
Request
curl https://api.manyfold.ai/api/v1/chat/completions \
-H "Authorization: Bearer $MF_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "agt_your_agent_id",
"messages": [
{ "role": "user", "content": "Summarize this repository." }
]
}' Streaming
Set stream to true to receive Server-Sent Events. The x-session-id response header identifies the Manyfold session.
curl -N https://api.manyfold.ai/api/v1/chat/completions \
-H "Authorization: Bearer $MF_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "agt_your_agent_id",
"stream": true,
"stream_options": { "include_usage": true },
"messages": [
{ "role": "user", "content": "Write a short release note." }
]
}' Response
- Non-streaming responses return chat.completion with choices[0].message.content.
- metadata.session_id and x-session-id identify the Manyfold conversation.
- Streaming responses emit chat.completion.chunk events followed by data: [DONE].
{
"object": "chat.completion",
"model": "agt_your_agent_id",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "..."
},
"finish_reason": "stop"
}
],
"metadata": {
"session_id": "cts_...",
"assistant_message_id": "..."
}
}