API Documentation
An OpenAI-compatible chat completion LLM API to easily integrate AI into your applications.
Quick Start
All mammouth subscribers have some credits included.
| Plan | Starter | Standard | Expert |
|---|---|---|---|
| Monthly credits | 2$ | 4$ | 10$ |
You can also subscribe on a pay-as-you-go basis directly from the API settings.
➡️ Get your API key and credits.
With the Mammouth API directly
Generates a chat completion response based on your prompt.
import requests
url = "https://api.mammouth.ai/v1/chat/completions"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "gpt-4.1",
"messages": [
{
"role": "user",
"content": "Explain the basics of machine learning"
}
]
}
response = requests.post(url, headers=headers, json=data)
print(response.json())const fetch = require("node-fetch");
async function callMammouth() {
const url = "https://api.mammouth.ai/v1/chat/completions";
const headers = {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
};
const data = {
model: "gpt-4.1",
messages: [
{
role: "user",
content: "Create an example JavaScript function",
},
],
};
try {
const response = await fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(data),
});
const result = await response.json();
console.log(result.choices[0].message.content);
} catch (error) {
console.error("Error:", error);
}
}
callMammouth();curl -X POST https://api.mammouth.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1",
"messages": [
{
"role": "user",
"content": "Hello, how are you doing?"
}
]
}'➡️ Get your API key and credits.
With OpenAI Library
import openai
# Configure the client to use Mammouth.ai
openai.api_base = "https://api.mammouth.ai/v1"
openai.api_key = "YOUR_API_KEY"
response = openai.ChatCompletion.create(
model="gpt-4.1",
messages=[
{"role": "user", "content": "What are the benefits of renewable energy?"}
]
)
print(response.choices[0].message.content)Response Format
Successful Response
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4.1",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I'm doing very well, thank you for asking. How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 19,
"total_tokens": 31
}
}Streaming Response
When stream: true is set, responses are returned as Server-Sent Events:
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-4.1","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"gpt-4.1","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
data: [DONE]{
"id": "gen-1767710235-3VtWd1SuI9ilIspBmeWG",
"created": 1767710235,
"model": "google/gemini-2.5-flash-image",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Here's a beautiful sunset over mountains for you!",
"role": "assistant",
"images": [
{
"image_url": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAI..."
}
}
]
}
}
]
}Models & Pricing
Mammouth Recommended
mammouth-recommended is a shortcut to whatever model Mammouth currently considers the best for its price.
Point your requests at it and you'll always get our current pick, without having to keep track of new releases yourself.
- Current pick:
glm-5.2, withminimax-m3as the fallback. This will change over time as new models come out. - How to use it: call it exactly like any other model. Set the model to
mammouth-recommended, or use the shortcutsmammouthorrecommended. - Pricing: you pay the same as the underlying model, with no markup, so check that model's row in the table below.
All models
Prices may vary and not be up to date in this table, please refer to the Model Explorer for the complete list of models !
| Model | Input ($/M tokens) | Output ($/M tokens) |
|---|---|---|
gpt-5.5 | 5 | 30 |
gpt-5.4 | 2.5 | 15 |
gpt-5.4-mini | 0.75 | 4.5 |
gpt-5.4-nano | 0.2 | 1.25 |
gpt-5.3-chat | 1.75 | 14 |
gpt-5.1 | 1.25 | 10 |
mistral-medium-3.1 | 0.4 | 2 |
mistral-small-2603 | 0.15 | 0.6 |
grok-4.3 | 1.25 | 2.5 |
gemini-3.1-flash-image-preview | image | / |
gemini-3.1-flash-lite-preview | 0.25 | 0.4 |
gemini-3-flash-preview | 0.3 | 1.5 |
gemini-3.1-pro-preview | 2.5 | 15 |
glm-5.2 | 1.4 | 4.4 |
glm-5.1 | 1.05 | 3.50 |
minimax-m3 | 0.3 | 1.2 |
deepseek-v4-flash | 0.14 | 0.28 |
deepseek-v4-pro | 1.74 | 3.48 |
kimi-k2.6 | 0.73 | 3.49 |
llama-4-maverick | 0.22 | 0.88 |
llama-4-scout | 0.15 | 0.6 |
sonar-pro | 3 | 15 |
sonar-deep-research | 2 | 8 |
claude-haiku-4-5 | 0.8 | 4 |
claude-opus-4.7 | 5 | 25 |
claude-sonnet-4-6 | 3 | 15 |
A note on pricing
The prices listed here are upper bounds.
What you actually pay is sometimes lower, since the price depends on provider availability.
You'll never be charged more than the price shown.
Embeddings
Generate vector embeddings for text to use in semantic search, clustering, and other NLP tasks.
Embedding Models & Pricing
| Model | Input ($/M tokens) |
|---|---|
text-embedding-3-large | 0.13 |
text-embedding-3-small | 0.02 |
Embedding Example
import requests
url = "https://api.mammouth.ai/v1/embeddings"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "text-embedding-3-large",
"input": "Hello, world!"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())Embedding Response
{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023, -0.0091, 0.0152, ...]
}
],
"model": "text-embedding-3-large",
"usage": {
"prompt_tokens": 4,
"total_tokens": 4
}
}📜 Usage and cost are logged in your settings.
💡 We added aliases aligned with the Mammouth app to facilitate your model selection: if you write mistral, it will use mistral-medium-3.1.
Error Codes
| Code | Description |
|---|---|
400 | Bad Request - Missing or incorrect parameters |
401 | Unauthorized - Invalid API key |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error - Server-side issue |
503 | Service Unavailable - Server temporarily unavailable |
Tracking cost
If you want to know how much credits has been spent on a key, use this API endpoint:
curl -X GET "http://0.0.0.0:4000/key/info" -H "Authorization: Bearer sk-test-example-key-123"Parameters
Required Parameters
| Parameter | Type | Description |
|---|---|---|
messages | array | List of messages in the conversation |
model | string | Model identifier to use |
Optional Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
temperature | number | 0.7 | Controls creativity (0.0 to 2.0) |
max_tokens | integer | 2048 | Maximum number of tokens to generate |
top_p | number | 1.0 | Controls response diversity |
stream | boolean | false | Real-time response streaming |
Optimization Tips
Message Structure
{
"messages": [
{
"role": "system",
"content": "You are an AI assistant specialized in programming."
},
{
"role": "user",
"content": "How to optimize a for loop in Python?"
}
]
}Role Types
system: Sets the behavior and context for the assistantuser: Represents messages from the userassistant: Represents previous responses from the AI
Migration from OpenAI
If you're already using OpenAI's API, migrating to Mammouth.ai is simple:
- Change the base URL from
https://api.openai.com/v1tohttps://api.mammouth.ai/v1 - Update your API key
- Keep all other parameters the same
OpenAI Python Library
import openai
# Before
openai.api_base = "https://api.openai.com/v1"
openai.api_key = "sk-openai-key"
# After
openai.api_base = "https://api.mammouth.ai/v1"
openai.api_key = "your-mammouth-key"n8n, VS Code, Cline, OpenClaw, Make, CLI, etc.
You can use the Mammouth API with tools like n8n, VS Code, Cline, Make and more.
Make sure you are using the correct URL. If unsure, try each of them.
- For base URL, https://api.mammouth.ai/v1 or https://api.mammouth.ai/
- For https queries, https://api.mammouth.ai/v1/chat/completions will be required.
Tutorials on how to use the Mammouth API in your favorite tools
For automations:
For IDEs:
For CLI (Claude Code equivalent):
Or via Opencode
Other
