API Reference
API Reference
The Mirai API is designed to be a drop-in replacement for OpenAI's API. You can use standard client libraries by simply changing the baseURL.
Base URL
Local URL
Authentication
The Mirai API uses API keys for authentication. Visit your dashboard to view and manage your API keys.
Authentication to the API is performed via HTTP Bearer Auth. Provide your API key as the Bearer token in the Authorization header.
Warning: Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.
curl https://api.mirai.com/v1/models \ -H "Authorization: Bearer $MIRAI_API_KEY"
Create chat completion
Creates a model response for the given chat conversation.
Body Parameters
ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
A list of messages comprising the conversation so far.
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random.
If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events.
curl https://api.mirai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MIRAI_API_KEY" \
-d '{
"model": "llama-3-70b",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "llama-3-70b",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello there, how may I assist you today?"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}List models
Lists the currently available models, and provides basic information about each one such as the owner and availability.
curl https://api.mirai.com/v1/models \ -H "Authorization: Bearer $MIRAI_API_KEY"
{
"object": "list",
"data": [
{
"id": "llama-3-70b",
"object": "model",
"created": 1686935002,
"owned_by": "meta"
},
{
"id": "mistral-large",
"object": "model",
"created": 1686935002,
"owned_by": "mistral-ai"
}
]
}