Create a chat completion
const url = 'https://api.saygm.com/v1/chat/completions';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"model":"gpt-5.5","messages":[{"role":"system","content":"example"}],"stream":false,"temperature":1,"max_tokens":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.saygm.com/v1/chat/completions \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "model": "gpt-5.5", "messages": [ { "role": "system", "content": "example" } ], "stream": false, "temperature": 1, "max_tokens": 1 }'OpenAI-compatible Chat Completions. Set stream: true for an incremental Server-Sent Events stream of chat.completion.chunk objects terminated by data: [DONE]; otherwise a single chat.completion object is returned.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Bare model id (no provider prefix); the gateway resolves the provider.
object
Stream the response as Server-Sent Events.
Responses
Section titled “Responses”When stream is false, a single chat.completion JSON object. When stream is true, a Server-Sent Events stream (text/event-stream) of chat.completion.chunk objects terminated by data: [DONE].
object
object
object
object
USD settled against the account for this request — the gateway’s settlement figure, not a catalog estimate. Rendered with exactly nine fractional digits.
The same settled amount in nano-USD (10^-9 USD), gm’s exact integer accounting unit.
Example
{ "object": "chat.completion", "choices": [ { "message": { "role": "system" } } ]}SSE stream of chat.completion.chunk objects, one per data: line, terminated by data: [DONE].
Invalid request (e.g. unknown model).
object
object
Examplegenerated
{ "error": { "message": "example", "type": "example", "code": "example" }}Missing or invalid gm API key.
object
object
Examplegenerated
{ "error": { "message": "example", "type": "example", "code": "example" }}Insufficient prepaid balance.
object
object
Examplegenerated
{ "error": { "message": "example", "type": "example", "code": "example" }}