Chat Completions
POST https://cpa.momoyai.com/v1/chat/completionsRequest body
Section titled “Request body”| Field | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | A model ID returned by /v1/models. |
messages |
array | Yes | Conversation messages in order. |
stream |
boolean | No | Return a server-sent event stream when true. |
temperature |
number | No | Adjust output randomness when supported by the target model. |
Non-streaming request
Section titled “Non-streaming request”curl https://cpa.momoyai.com/v1/chat/completions \ -H "Authorization: Bearer $MOMOYAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.4", "messages": [ {"role": "system", "content": "Be concise and accurate."}, {"role": "user", "content": "What is idempotency?"} ] }'Read the first text response defensively:
const content = response.choices[0]?.message.content ?? "";Streaming request
Section titled “Streaming request”Set stream to true. Consume Server-Sent Events incrementally and close the connection on cancellation, network failure, or timeout. See Streaming.