POST /v1/chat/completions takes an OpenAI chat completion request, searches the indexes the call names for the user’s message, and returns the reply in OpenAI’s shape. Any OpenAI client works once you change the base URL and the key.
Base URL
Authentication
Send your project id and project key from the Moss portal as one bearer token:Request
The body is an OpenAI chat completion request.
On the Moss key, a vendor model refuses some fields with
400 and code unsupported_parameter. Models lists them.
Headers
Request headers
Reply headers
System prompt
A project can have its own system prompt. Set it in the Moss portal, on the Prompt tab of the Moss Inference page. Moss uses it when a request has no system message. A request whose first message is asystem or developer message with text uses that message instead, and the project’s prompt is not added. An empty one counts as no system message. X-Moss-System-Prompt: off turns the project’s prompt off for one request. The project’s prompt counts toward the request’s prompt tokens and its context limit. A change to the prompt takes effect within about a minute.
Response
Withoutstream, the body is one OpenAI chat.completion.
Streaming
Withstream: true, the reply is a series of server-sent chat.completion.chunk events. The last chunk before data: [DONE] has empty choices and the whole reply’s usage. No other chunk carries usage.
choices before you read choices[0]. A failure after the stream starts arrives as a final data: frame carrying error instead of choices, then data: [DONE]. Streaming shows how to read the chunks and stop early.
Examples
The Python and JavaScript tabs use OpenAI’s own clients. The Moss SDKs call Responses instead. Each example streams a reply grounded in thefaq index from the Quickstart.
Limits
Each project has per-minute request and token limits, and each request has limits on prompt tokens, indexes and body size. The values formoss/fastlane-1 and vendor models are in Errors and limits.
Errors
Errors use OpenAI’s{"error": {"message", "type", "code"}} shape. Every status and code, with what to do about it, is in Errors and limits.
Tool calls
tools, tool_choice and parallel_tool_calls take OpenAI’s shapes. Your code runs the function tools. Moss runs moss_search and mcp tools for the model, as the next two sections show. Tool calling shows the loop and the messages to send back for function tools.
Moss search tool
Atools entry of type moss_search lets the model search your project’s indexes. Moss runs each search, and your code does not. Moss search tool has the entry’s fields.
MCP servers
Atools entry of type mcp names a server that Moss runs for the model. MCP servers has the entry’s fields. Tool steps has the moss_tool_step chunks a stream carries.
MCP errors
Never replay a request that failed withfailed_after_tool_call. The other MCP errors are in MCP servers.