API DocsAPI Docs
LongCat API Platform
  • English
  • 简体中文
LongCat API Platform
  • English
  • 简体中文
  • Quick Start
  • API Docs
  • Claude Code Configuration
  • Kilo Code Configuration
  • OpenCode Configuration
  • OpenClaw Configuration
  • Codex Configuration
  • FAQ
  • Change Log

LongCat API Platform Interface Documentation

Overview

The LongCat API Platform provides AI model proxy services exclusively for the LongCat series models, while maintaining compatibility with OpenAI and Anthropic API formats. This documentation follows standard API format conventions.

Base URLs

Production Endpoint: https://api.longcat.chat

Authentication

All API requests require authentication using an API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Endpoints

Chat Completions

POST /openai/v1/chat/completions

Create a chat completion using OpenAI-compatible format.

Headers

  • Authorization: Bearer YOUR_API_KEY (required)
  • Content-Type: application/json

Request Body

FieldTypeRequiredDescription
modelstringYesModel identifier
messagesarrayYesArray of message objects, only text inputs are allowed
streambooleanNoWhether to stream the response (default: false)
max_tokensintegerNoMaximum number of tokens to generate, the default value for LongCat-2.0-Preview is 32768, and is supported up to 131072 tokens
temperaturenumberNoSampling temperature between 0 and 1
top_pnumberNoNucleus sampling parameter

Message Object

FieldTypeRequiredDescription
rolestringYesThe role of the message author. Must be one of:
• system - Sets the behavior and context for the assistant
• user - Messages from the human user
• assistant - Messages from the AI assistant (for conversation history)
contentstringYesThe message content. A string for simple text messages.

Example Request

{
  "model": "LongCat-2.0-Preview",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "Hello, how are you?"
    }
  ],
  "stream": false,
  "max_tokens": 150,
  "temperature": 0.7
}

Response (Non-streaming)

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "LongCat-2.0-Preview",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm doing well, thank you for asking. How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 15,
    "total_tokens": 35
  }
}

Response (Streaming)

When stream: true, the response is returned as Server-Sent Events (SSE):

Content-Type: text/event-stream

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"LongCat-2.0-Preview","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"LongCat-2.0-Preview","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"LongCat-2.0-Preview","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}

data: [DONE]

Anthropic Messages

POST /anthropic/v1/messages

Create a message using Anthropic's Claude API format.

Headers

  • Authorization: Bearer YOUR_API_KEY (required)
  • Content-Type: application/json

Request Body

FieldTypeRequiredDescription
modelstringYesThe Claude model to use
messagesarrayYesArray of message objects
max_tokensintegerNoMaximum number of tokens to generate
streambooleanNoWhether to stream the response (default: false)
temperaturenumberNoSampling temperature between 0 and 1
top_pnumberNoNucleus sampling parameter
systemstringNoSystem message to set context

Message Object

FieldTypeRequiredDescription
rolestringYesThe role of the message author. Must be one of:
• user - Messages from the human user
• assistant - Messages from Claude (for conversation history)
Note: System messages are passed separately via the system parameter
contentstringYesThe message content. A string for text-only messages

Example Request

{
  "model": "LongCat-2.0-Preview",
  "max_tokens": 1000,
  "messages": [
    {
      "role": "user",
      "content": "Hello, LongCat"
    }
  ],
  "stream": false,
  "temperature": 0.7
}

Response (Non-streaming)

{
  "id": "msg_123",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Hello! How can I help you today?"
    }
  ],
  "model": "LongCat-2.0-Preview",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 10,
    "output_tokens": 8
  }
}

Response (Streaming)

When stream: true, the response follows Anthropic's SSE format:

Content-Type: text/event-stream

event: message_start
data: {"type": "message_start", "message": {"id": "msg_123", "type": "message", "role": "assistant", "content": [], "model": "LongCat-2.0-Preview", "stop_reason": null, "stop_sequence": null, "usage": {"input_tokens": 10, "output_tokens": 0}}}

event: content_block_start
data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}

event: content_block_delta
data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "Hello"}}

event: content_block_delta
data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "!"}}

event: content_block_stop
data: {"type": "content_block_stop", "index": 0}

event: message_delta
data: {"type": "message_delta", "delta": {"stop_reason": "end_turn", "stop_sequence": null}, "usage": {"output_tokens": 8}}

event: message_stop
data: {"type": "message_stop"}

Models API

GET /v1/models

Lists the available LongCat models under both the openai and anthropic endpoints, providing basic information about each model.

EndpointDescription
/openai/v1/modelsGet the list of models under the openai endpoint
/anthropic/v1/modelsGet the list of models under the anthropic endpoint

Headers

  • Authorization: Bearer YOUR_API_KEY (required)
  • Content-Type: application/json

Example:

curl --location 'https://api.longcat.chat/openai/v1/models' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json'
curl --location 'https://api.longcat.chat/anthropic/v1/models' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json'

Example response:

{
    "object": "list",
    "data": [
        {
            "id": "LongCat-2.0-Preview",
            "object": "model",
            "owned_by": "LongCat"
        }
    ]
}

GET /v1/models/{model}

Retrieves the details of a LongCat model under both the openai and anthropic endpoints, including modalities, pricing, and other information.

EndpointDescription
/openai/v1/models/{model}Get model details under the openai endpoint
/anthropic/v1/models/{model}Get model details under the anthropic endpoint

Headers

  • Authorization: Bearer YOUR_API_KEY (required)
  • Content-Type: application/json

Example:

curl --location 'https://api.longcat.chat/openai/v1/models/LongCat-2.0-Preview' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json'

Example response:

{
  "id": "LongCat-2.0-Preview",
  "name": "LongCat-2.0-Preview",
  "created": 1773331200,
  "context_length": 1048576,
  "architecture": {
    "input_modalities": [
      "text"
    ],
    "output_modalities": [
      "text"
    ],
    "modality": "text->text",
    "tokenizer": "Other",
    "instruct_type": null
  },
  "supported_parameters": [
    "max_tokens",
    "temperature",
    "top_p",
    "stream",
    "tools",
    "tool_choice"
  ],
  "pricing": {
    "prompt": "0",
    "completion": "0"
  }
}

Error Responses

The API uses conventional HTTP response codes to indicate success or failure:

HTTP Status Codes

Status CodeStatus NameDescription
200OKRequest successful
400Bad RequestInvalid request parameters or malformed JSON
401UnauthorizedInvalid or missing API key
403ForbiddenAPI key doesn't have permission for the requested resource
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer encountered an unexpected condition
502Bad GatewayInvalid response from upstream server
503Service UnavailableServer temporarily unavailable

Error Response Format

All errors return a JSON object with the following structure:

{
  "error": {
    "message": "Human-readable error description",
    "type": "error_type_identifier", 
    "code": "specific_error_code"
  }
}

Error Types and Codes

Error TypeError CodeHTTP StatusDescription
authentication_errorinvalid_api_key401Invalid API key provided
permission_errorinsufficient_quota403API key has insufficient quota
invalid_request_errorinvalid_parameter400Invalid parameter value
invalid_request_errorinvalid_json400Invalid JSON format
rate_limit_errorrate_limit_exceeded429Too many requests in a short period
server_errorinternal_error500Internal server error

Example Error Responses

Invalid API Key

{
  "error": {
    "message": "Invalid API key provided",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}

Rate Limit Exceeded

{
  "error": {
    "message": "Rate limit exceeded. Please try again in 60 seconds",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded"
  }
}

Rate Limiting

Rate limits are enforced per API key. When exceeded, you'll receive a 429 status code.

SDK Compatibility

This API is designed to be compatible with:

  • OpenAI Python SDK (for /openai/ endpoints)
  • Anthropic Python SDK (for /anthropic/ endpoints)
  • Any HTTP client that supports the respective API formats

Examples

Using with OpenAI Python SDK

import openai

# Configure for LongCat API
openai.api_base = "https://api.longcat.chat/openai"
openai.api_key = "your-api-key"

response = openai.ChatCompletion.create(
    model="LongCat-2.0-Preview",
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)

Using with Anthropic Python SDK

import anthropic

# Configure for LongCat API  
client = anthropic.Anthropic(
    api_key="Bearer your-api-key",
    base_url="https://api.longcat.chat"
)
default_headers={
        "Content-Type": "application/json",
        "Authorization": "Bearer your-api-key",
    }


message = client.messages.create(
    model="LongCat-2.0-Preview",
    max_tokens=150,
    messages=[
        {"role": "user", "content": "Hello, LongCat!"}
    ]
)

Using with cURL

# OpenAI-style request
curl -X POST https://api.longcat.chat/openai/v1/chat/completions \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "LongCat-2.0-Preview",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": false
  }'

# Anthropic-style request
curl -X POST https://api.longcat.chat/anthropic/v1/messages \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "LongCat-2.0-Preview",
    "max_tokens": 1000,
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

📋 Need Help? Check out our comprehensive FAQ for common questions and troubleshooting guide.

Last Updated: 5/28/26, 11:44 AM
Prev
Quick Start
Next
Claude Code Configuration