Home / Guides
LongCat 2.0 API Quickstart: OpenAI-Compatible Calls in 5 Minutes
Self-hosting a 1.6T-parameter MoE model is serious infrastructure. For most developers, the managed API is the sensible way to use LongCat 2.0 โ and because it is OpenAI-compatible, existing code usually works with a two-line change. This quickstart covers the official route plus one alternative.
1. Get an API key
Sign up on the official platform at longcat.chat/platform/product and create an API key in the console. The full English reference lives in the API documentation โ the endpoints are compatible with both the OpenAI and Anthropic SDK conventions.
2. Make your first call (Python)
Install the OpenAI SDK and point it at the LongCat base URL from the docs:
pip install openai
from openai import OpenAI
client = OpenAI(
api_key="YOUR_LONGCAT_API_KEY",
base_url="https://api.longcat.chat/openai", # see official docs for the current base URL
)
resp = client.chat.completions.create(
model="LongCat-2.0",
messages=[{"role": "user", "content": "Explain MoE routing in one paragraph."}],
)
print(resp.choices[0].message.content)
Always copy the exact base_url and model name from the official docs rather than from blog posts โ these details can change between platform updates.
3. Make your first call (cURL)
curl https://api.longcat.chat/openai/v1/chat/completions \
-H "Authorization: Bearer YOUR_LONGCAT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "LongCat-2.0",
"messages": [{"role": "user", "content": "Hello, LongCat!"}]
}'
4. Migrating existing OpenAI code
If your app already uses the OpenAI SDK, migration is usually just:
- Swap
api_keyfor your LongCat key. - Swap
base_urlfor the LongCat endpoint. - Swap the model name for a LongCat model identifier.
Streaming (stream=True), system prompts and multi-turn history all work the same way. Check the docs for the current limits on context length โ one of LongCat 2.0's headline features is a context window of up to 1M tokens, but the tier you are on may cap requests lower.
5. Alternative: OpenRouter
If you already use OpenRouter as a model hub, LongCat 2.0 is also available there (it previously appeared on the platform under the codename "Owl Alpha"). This is convenient for side-by-side benchmarking against other models with a single API key, though the official platform is the canonical source for pricing and rate limits.
6. When to self-host instead
The API is the right default. Consider downloading the MIT-licensed weights and self-hosting when you need: data residency guarantees, fine-tuning, offline operation, or sustained high volume where per-token billing exceeds GPU amortized cost. Our download and deploy guide covers that path.
Reminder: API endpoints, model names and pricing are controlled by the official longcat.chat platform. This quickstart is maintained by an independent community site โ treat the official docs as the source of truth.