Quickstart
Get started with AllToken
AllToken provides a unified API that gives you access to hundreds of AI models through a single endpoint, while automatically handling fallbacks and selecting the most cost-effective options. Get started with just a few lines of code using your preferred SDK or framework.
Before getting started, go to Settings → API Keys to create your API key. The key is shown only once — save it securely.
Using the AllToken SDK (Beta)
First, install the SDK:
npm
yarn
pnpm
npm install @alltoken/sdkThen use it in your code:
TypeScript SDK
import { AllToken } from '@alltoken/sdk';
const allToken = new AllToken({
apiKey: '<ALLTOKEN_API_KEY>',
});
const completion = await allToken.chat.send({
model: 'minimax-m2.5',
messages: [
{
role: 'user',
content: 'What is the meaning of life?',
},
],
stream: false,
});
console.log(completion.choices[0].message.content);Using the OpenAI SDK
AllToken is fully compatible with the OpenAI SDK. Just point the base_url to AllToken.
TypeScript
Python
import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: 'https://api.alltoken.ai/api-chat/v1',
apiKey: '<ALLTOKEN_API_KEY>',
});
async function main() {
const completion = await openai.chat.completions.create({
model: 'minimax-m2.5',
messages: [
{
role: 'user',
content: 'What is the meaning of life?',
},
],
});
console.log(completion.choices[0].message);
}
main();Using the AllToken API directly
You can also call the API using standard HTTP requests without any SDK.
Python
TypeScript (fetch)
Shell
import requests
import json
response = requests.post(
url="https://api.alltoken.ai/api-chat/v1/chat/completions",
headers={
"Authorization": "Bearer <ALLTOKEN_API_KEY>",
},
data=json.dumps({
"model": "minimax-m2.5",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
})
)Streaming
The API also supports streaming. See the streaming documentation for details.
Next Steps
API Reference · Streaming · Routing