Skip to content

Chat Completions

POST https://cpa.momoyai.com/v1/chat/completions
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.
Terminal window
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 ?? "";

Set stream to true. Consume Server-Sent Events incrementally and close the connection on cancellation, network failure, or timeout. See Streaming.