Skip to main content
POST
Create a Messages response
Creates a Messages-style response from user and assistant turns. Content can be a string or an array of text, image, document, and tool blocks.

Authorization

Send either header:
string
Magica API key, such as gx_your_api_key.
string
Bearer form: Bearer gx_your_api_key.

Body

string
required
Model ID from the language-model catalog.
integer
Optional output-token ceiling. When omitted, Magica applies the selected model’s bounded gateway default when that model declares one.
array
required
User and assistant turns. Send the complete history needed for this answer. Models using the native Messages format also accept system turns after a user turn. Each system turn must contain nonempty text, either as a string or an array of text blocks. These turns retain their position in the conversation and cannot be translated to another model’s wire format.
string | array
Initial system instructions as text or content blocks. Use this field, not an initial system turn in messages, for instructions before the first user turn.
boolean
default:"false"
Omit or set false for one complete JSON object. Set true for named SSE events.
array
Tool definitions with name, optional description, and input_schema.
object
Controls automatic, required, disabled, or named tool use.

Direct JSON request

Direct JSON response

Stream the response

Add "stream": true. A text response normally starts with message_start, emits content block events, reports its final stop reason and usage in message_delta, and ends with message_stop.
This stream does not use a [DONE] sentinel.

Images and PDFs

  • Image: {"type":"image","source":{"type":"url","url":"https://..."}}
  • PDF: {"type":"document","source":{"type":"url","url":"https://..."}}
Base64 image data and base64 PDF data are also accepted. Prefer HTTPS URLs for large attachments.

Errors

Errors use the Messages-style error object.