Skip to content

API Documentation ​

An OpenAI-compatible chat completion LLM API to easily integrate AI into your applications.

Quick Start ​

💡 If you mainly use the API with developer tools such as Mammouth Code or Cline, choose the Starter plan and add $10 in API credits instead of choosing Standard.

➡️ Get your API key and credits.

Manage your API budget ​

Use the API settings to manage spending and avoid service interruptions:

  • Set a monthly limit to control your budget.
  • Set a 3-hour usage limit to keep short-term usage in check.
  • Turn on automatic top-up to add credits when your balance runs low and keep using the API without interruption.

API credits are independent from your Mammouth chat quota. Manage your credits and limits in the API settings.

With the Mammouth API directly ​

Generates a chat completion response based on your prompt.

python
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())
javascript
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();
bash
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 ​

python
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 ​

json
{
  "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]
json
{
  "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 is a shortcut to the model Mammouth currently considers the best value for money.

Point your requests at it and you'll always get our current pick, without having to keep track of new releases yourself.

  • Current pick: gpt-6-luna, with glm-5.3-flash as a fallback. This pick may evolve as new models are released.
  • How to use it: call it exactly like any other model. Set the model to mammouth-recommended, or use the shortcuts mammouth or recommended.
  • Pricing: you pay the same as the underlying model, with no markup, so check that model's row in the table below.

All models ​

This table lists the latest models in each family and range. Prices are shown in US dollars per million tokens. The complete, up-to-date list is available in the Model Explorer.

ModelInput ($/M tokens)Output ($/M tokens)
claude-fable-5.28.0040.00
claude-haiku-5-50.100.50
claude-opus-5-54.0020.00
claude-sonnet-5-52.0010.00
deepseek-v4.1-flash0.220.66
deepseek-v4-pro1.323.96
gemini-4-argon4.0020.00
gemini-4-carbon4.0020.00
gemini-4-hydrogen1.507.50
gemini-4-neon3.0015.00
gemini-nano-banana-2.11.507.50
glm-5.31.404.40
glm-5.3-flash0.150.50
gpt-6.2-astra8.0040.00
gpt-6.2-sol2.0010.00
gpt-6-luna0.100.50
gpt-image-21.507.50
grok-4.72.006.00
kimi-k33.0015.00
kimi-k3.1-pro2.0010.00
kimi-k3-fast4.5022.50
mistral-large-41.364.18
mistral-medium-3-51.507.50
mistral-small-26030.150.60
muse-spark-open1.254.25
qwen3.8-27b0.202.50
qwen3.8-2.4t-a95b2.006.00

About 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 ​

ModelInput ($/M tokens)
text-embedding-3-large0.13
text-embedding-3-small0.02

Embedding Example ​

python
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 ​

json
{
  "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 claude, it will use claude-sonnet-5-5.

Error Codes ​

CodeDescription
400Bad Request - Missing or incorrect parameters
401Unauthorized - Invalid API key
429Too Many Requests - Rate limit exceeded
500Internal Server Error - Server-side issue
503Service Unavailable - Server temporarily unavailable

Tracking cost ​

If you want to know how much credits has been spent on a key, use this API endpoint:

bash
curl -X GET "https://api.mammouth.ai/key/info" -H "Authorization: Bearer $MAMMOUTH_API_KEY"

Parameters ​

Required Parameters ​

ParameterTypeDescription
messagesarrayList of messages in the conversation
modelstringModel identifier to use

Optional Parameters ​

ParameterTypeDefaultDescription
temperaturenumber0.7Controls creativity (0.0 to 2.0)
max_tokensinteger2048Maximum number of tokens to generate
top_pnumber1.0Controls response diversity
streambooleanfalseReal-time response streaming

Our API also supports provider-specific parameters and features, such as reasoning effort, tool calling, function calling, and thinking. Availability depends on the provider and model.

Optimization Tips ​

Message Structure ​

json
{
  "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 assistant
  • user: Represents messages from the user
  • assistant: Represents previous responses from the AI

Migration from OpenAI ​

If you're already using OpenAI's API, migrating to Mammouth.ai is simple:

  1. Change the base URL from https://api.openai.com/v1 to https://api.mammouth.ai/v1
  2. Update your API key
  3. Keep all other parameters the same

OpenAI Python Library ​

python
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.

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

​