Documentação da API
A Mangaba AaaS oferece uma API compatível com OpenAI para acessar múltiplos modelos de IA. Use qualquer SDK OpenAI com nossa plataforma.
https://mangaba-api.up.railway.app/api/v1
Alta Performance
Respostas rápidas com streaming em tempo real.
32+ Modelos
OpenAI, Anthropic, Google, Meta e mais.
Autenticação
Use Bearer Token com sua API Key em todas as requisições:
curl -X POST https://mangaba-api.up.railway.app/api/v1/chat/completions \
-H "Authorization: Bearer mk-sua-api-key-aqui" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-4o-mini", "messages": [{"role": "user", "content": "Olá!"}]}'
Segurança
Nunca exponha sua API Key em código frontend ou repositórios públicos. Use variáveis de ambiente.
Providers Suportados
A Mangaba AaaS roteia suas requisições para o melhor provider disponível:
OpenRouter
200+ modelosGateway para múltiplos providers com preços competitivos.
Vercel AI Gateway
EnterpriseGateway unificado da Vercel com observabilidade avançada.
Chat Completions
/api/v1/chat/completions
Parâmetros
| Parâmetro | Tipo | Obrigatório | Descrição |
|---|---|---|---|
model |
string | ✓ | ID do modelo (ex: openai/gpt-4o-mini) |
messages |
array | ✓ | Lista de mensagens com role e content |
temperature |
float | - | Criatividade (0-2, padrão: 0.7) |
max_tokens |
integer | - | Máximo de tokens na resposta |
stream |
boolean | - | Ativar streaming SSE |
Exemplo Python
from mangaba import MangabaAI
client = MangabaAI(api_key="mk-sua-api-key")
response = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[
{"role": "system", "content": "Você é um assistente útil."},
{"role": "user", "content": "Explique Python em 3 frases."}
],
temperature=0.7,
max_tokens=500
)
print(response.choices[0].message.content)
# Informações de custo (exclusivo Mangaba)
print(f"Custo: ${response.mangaba_usage['total_cost_usd']:.6f}")
print(f"Provider: {response.mangaba_usage['provider_name']}")
Exemplo JavaScript
import MangabaAI from 'mangaba';
const client = new MangabaAI({ apiKey: 'mk-sua-api-key' });
const response = await client.chat.completions.create({
model: 'openai/gpt-4o-mini',
messages: [
{ role: 'system', content: 'Você é um assistente útil.' },
{ role: 'user', content: 'Explique JavaScript em 3 frases.' }
]
});
console.log(response.choices[0].message.content);
console.log('Custo:', response.mangaba_usage?.total_cost_usd);
Exemplo Go
package main
import (
"context"
"fmt"
"github.com/mangaba-ai/mangaba-go"
)
func main() {
client := mangaba.NewClient("mk-sua-api-key")
resp, _ := client.Chat.Completions.Create(context.Background(), mangaba.ChatRequest{
Model: "openai/gpt-4o-mini",
Messages: []mangaba.Message{
{Role: "user", Content: "Olá! Como funciona Go?"},
},
})
fmt.Println(resp.Choices[0].Message.Content)
}
Exemplo cURL/REST
curl https://mangaba-api.up.railway.app/api/v1/chat/completions \
-H "Authorization: Bearer mk-sua-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "Olá!"}]
}'
Listar Modelos
/api/v1/models
Retorna todos os modelos disponíveis com informações de preço.
curl https://mangaba-api.up.railway.app/api/v1/models
Modelos Disponíveis
tngtech/deepseek-r1t2-chimera:free
kwaipilot/kat-coder-pro:free
nvidia/nemotron-nano-12b-v2-vl:free
mistralai/devstral-2512:free
tngtech/deepseek-r1t-chimera:free
z-ai/glm-4.5-air:free
tngtech/tng-r1t-chimera:free
amazon/nova-2-lite-v1:free
allenai/olmo-3-32b-think:free
qwen/qwen3-coder:free
openai/gpt-oss-20b:free
google/gemma-3-27b-it:free
meta-llama/llama-3.3-70b-instruct:free
qwen/qwen3-235b-a22b:free
google/gemini-2.0-flash-exp:free
nex-agi/deepseek-v3.1-nex-n1:free
meituan/longcat-flash-chat:free
alibaba/tongyi-deepresearch-30b-a3b:free
cognitivecomputations/dolphin-mistral-24b-venice-edition:free
arcee-ai/trinity-mini:free
mistralai/mistral-7b-instruct:free
nousresearch/hermes-3-llama-3.1-405b:free
nvidia/nemotron-nano-9b-v2:free
openai/gpt-oss-120b:free
mistralai/mistral-small-3.1-24b-instruct:free
moonshotai/kimi-k2:free
meta-llama/llama-3.2-3b-instruct:free
qwen/qwen3-4b:free
google/gemma-3-12b-it:free
google/gemma-3n-e2b-it:free
google/gemma-3-4b-it:free
google/gemma-3n-e4b-it:free
Monitorar Uso
/api/v1/usage
Retorna estatísticas de uso e custos da sua API key.
curl https://mangaba-api.up.railway.app/api/v1/usage \
-H "Authorization: Bearer mk-sua-api-key"
Resposta
{
"key": {
"name": "Chave Principal",
"prefix": "mk-abc1...xyz9",
"total_requests": 1542,
"total_tokens_input": 125000,
"total_tokens_output": 87000,
"total_cost_usd": 4.75,
"cost_this_month_usd": 2.30,
"monthly_budget_usd": 50.00
},
"account": {
"plan": "pro",
"credits_balance_usd": 45.25,
"credits_used_this_month_usd": 4.75
}
}
Testar API Key
/api/v1/test
Valida sua API key e retorna informações do usuário e limites.
curl -X POST https://mangaba-api.up.railway.app/api/v1/test \
-H "Authorization: Bearer mk-sua-api-key"
Health Check
/api/v1/health
Verifica status da API e provider ativo.
curl https://mangaba-api.up.railway.app/api/v1/health
Streaming
Use stream: true para receber a resposta em tempo real via SSE:
from mangaba import MangabaAI
client = MangabaAI(api_key="mk-sua-api-key")
stream = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Conte uma história curta"}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
Códigos de Erro
| Código | Significado | Ação |
|---|---|---|
400 |
Bad Request | Verifique os parâmetros |
401 |
Unauthorized | API Key inválida |
402 |
Payment Required | Créditos insuficientes |
403 |
Forbidden | Modelo não permitido no plano |
429 |
Rate Limited | Aguarde e tente novamente |
500 |
Server Error | Erro no provider |
Rate Limits
Os limites variam de acordo com seu plano:
SDKs Oficiais Mangaba
Use nossos SDKs oficiais para uma integração simplificada:
Python
pip install mangaba
from mangaba import MangabaAI
client = MangabaAI(api_key="mk-...")
Node.js
npm install mangaba
import MangabaAI from 'mangaba';
const client = new MangabaAI({ apiKey: 'mk-...' });
Interface Familiar
O SDK MangabaAI usa a mesma interface do OpenAI. Você pode migrar projetos existentes apenas mudando o import!