Skip to content

API

Models API

One endpoint for chat. Name a model, or send auto.

POST /v1/ai/chat

Send messages to a model, or to auto; the reply says which model answered and what it cost.

The request body
FieldWhat it is
modelA model id from the Model Hub, or auto. Required.
messagesThe conversation: each has a role (system, user or assistant) and content. Required.
temperatureHow varied the wording is. Optional.
max_tokensThe most the model may write. Optional.
streamTrue to receive the answer as it is written. Optional.
JSON
{
  "model": "auto",
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ]
}

The reply has the model’s answer and model, provider, fallback and usage (tokens, credits, remaining). With auto it also has routing: the task it was sorted into and how many models qualified. See routing.

What the catalog can serve now

  • Text: 54 models
  • Image: no model in the catalog yet
  • Video: no model in the catalog yet
  • Audio: no model in the catalog yet
  • Embeddings: no model in the catalog yet

Common questions

Which endpoint sends a message to a model?

POST /v1/ai/chat at https://api.mayuai.com, with an API key or an account token.

What does the request body need?

A model and the messages are required. Temperature, a maximum length and stream are optional.

How do I get the answer as it is written?

Set stream to true in the request.

How do I know which model answered and what it cost?

The reply carries the model, the provider, whether another model was tried, and the usage: tokens, credits charged and credits remaining. With auto it also says the kind of task the request was sorted into.

Where to go next

  • How auto chooses

    The rules behind the model auto.

    Open
  • Usage and credits

    Where to read the cost of a request.

    Open
  • The Model Hub

    Model ids and their credit rates.

    Open
  • Plans and limits

    Plans

    What each plan includes.

    Open

Not open to the public yet

One endpoint for chat: name a model or send auto, and read which model answered and what it cost.

Existing accounts can sign in. To ask about access, contact us.