Create a chat completion
OpenAI’s Chat Completions API. model is ambral/auto with an x-workload header (or ambral/auto:<workload>), which serves the workload’s primary model and records the call to its traces. The answer is in Chat Completions’ own response schema, with id the call’s own id, model the model that served it, and usage.cost what the call costs, in USD; any other key the provider adds is removed. With stream: true the answer is server-sent events, one chunk each, ending with data: [DONE]. A failure after the 200 is a chunk whose error says what failed, or the error envelope when Ambral couldn’t read the provider’s event, and a provider whose connection drops ends the stream without [DONE]. Otherwise it is one JSON completion, or the error envelope when Ambral couldn’t read it. An error the provider answers reaches the client with the provider’s status, in the same error envelope. Every top-level key Chat Completions names, and the provider’s own extension keys, are passed through as they were sent; any other key is left out. A request Ambral must price and can’t is a 400: one that would let the provider choose another model, or run a tool or add-on Ambral doesn’t price.
Headers
<run>; workload=<workload>; model=<model>: the request is a call of an eval run, which Ambral's SDKs set. A request that names no workload (no x-workload, no model suffix) is for the run's. A request for the run's workload is served the run's model, one of the workload's pool, and a request for another workload that workload's primary. Either way it is recorded as an eval trace of the run, never as production. It needs a session, and a value that doesn't parse is a 400.
Labels on the request's session, key=value or a bare tag, comma-separated: up to 16. A key is lowercase letters, digits, ., _ and -, starting with a letter or digit, at most 63 characters. A value is letters, digits, spaces and . _ : / @ + -, at most 128 characters; spaces around it are dropped. A session's labels gather every request's, a later value replacing an earlier one's; once a session holds 16, a later request's new keys are dropped. Invalid labels are ignored, all of them, and the response says why in its own x-ambral-labels header.
Body
Response
The provider's answer: one completion, or a stream of chunks.
- Option 1
- Option 2
The completion, or the error envelope when Ambral couldn't read the provider's answer.