API DocsAPI Docs
LongCat API Platform
  • English
  • 简体中文
LongCat API Platform
  • English
  • 简体中文
  • Quick Start
  • API Docs
  • Claude Code Configuration
  • OpenClaw 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 (only LongCat-Flash-Chat is supported)
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 is 131072 for LongCat-Flash-Chat, and 262144 for other models. LongCat-Flash-Chat, LongCat-Flash-Thinking and LongCat-Flash-Thinking-2601 are supported up to 262144 tokens; LongCat-Flash-Lite is supported up to 327680 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-Flash-Chat",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "Hello, how are you?"
    }
  ],
  "stream": false,
  "max_tokens": 150,
  "temperature": 0.7
}

Example Request(Thinking)

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

Response (Non-streaming)

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "LongCat-Flash-Chat",
  "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-Flash-Chat","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}

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

data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1677652288,"model":"LongCat-Flash-Chat","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-Flash-Chat",
  "max_tokens": 1000,
  "messages": [
    {
      "role": "user",
      "content": "Hello, LongCat"
    }
  ],
  "stream": false,
  "temperature": 0.7
}

Example Request(Thinking)

{
  "model": "LongCat-Flash-Thinking-2601",
  "messages": [
    {
      "role": "user",
      "content": "Hello, how are you?"
    }
  ],
  "system": "You are a helpful assistant.",
  "stream": false,
  "max_tokens": 1500,
  "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-Flash-Chat",
  "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-Flash-Chat", "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"}

Omni-Modal Chat Completions

POST /openai/v1/chat/completions

Create a chat completion using omni-modal format supporting mixed input and output of text, audio, images, and video, generating text or audio responses.

Headers

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

Request Body

FieldTypeRequiredDescription
session_idstringNoUser-provided parameter that must be unique; used to distinguish each request's unique identifier. Generates by default when not provided by user. UUID is recommended.
modelstringYesThe name of the model to call
messagesarrayYesList of conversation information to be passed to the model as prompt input in JSON array format
max_tokensintegerNoMaximum tokens for model output, default value is 4096, range: (1, 8192]
temperaturenumberNoSampling temperature controlling randomness of output, must be positive. Range: (0.0, 2.0], default: 1. Larger values make output more random and creative; smaller values make output more stable or deterministic
top_pnumberNoAn alternative sampling method called nucleus sampling. Range: (0.0, 1.0], default: 0.1. Model considers tokens with top_p probability mass
top_kintegerNoDefault value: 1, range: [1, 50]
text_repetition_penaltynumberNoText repetition penalty factor to reduce repetition in text. Default: 1.1. Typically between 1.0 and 2.0, where 1.0 means no penalty
audio_repetition_penaltynumberNoAudio repetition penalty factor, default: 1.2. Typically between 1.0 and 2.0
audioAudioConfigNoAudio configuration. Uses default configuration when empty
output_modalitiesarrayNoOutput modalities, can be ["text"] or ["text","audio"], default: ["text","audio"]
streambooleanNoDefault: true. If true, model returns generated content in chunks via standard Event Stream. Returns data: [DONE] when stream ends. If false, returns segmented content in JSON format

AudioConfig Audio Configuration Parameters

FieldTypeRequiredDescription
voicestringNoVoice setting, default: yangguangtianmei, available options: yangguangtianmei, linjiajiejie, zhixingxuejie, meishuman, meishuqing, meifannan, huolixuedi, linjiananhai, guiguozongcai, miaolingshaonv, meishumu
speedintegerNoSpeech speed, range: (0-100], default: 50
volumeintegerNoVolume, range: (0-100], default: 50. 100 is maximum volume corresponding to 0dBFS, 50 corresponds to -6dBFS
output_audio_samplerateintegerNoOutput audio sample rate, supports 8000, 16000, 24000, default: 24000

Message Object Structure

Each object in the message array contains role and content fields. Different format requirements based on role type:

System Message Format

FieldTypeRequiredDescription
rolestringYesMessage author role, should be system in this case
contentarrayYesMessage content array containing text objects

User Message Format

FieldTypeRequiredDescription
rolestringYesMessage author role, should be user in this case
contentarrayYesMessage content array, can contain text, input_audio, input_image, input_video and other types

content Array Element Description

  • Text Content (type: text)

    • type: "text" (required)
    • text: Text content string (required)
  • Audio Content (type: input_audio)

    • type: "input_audio" (required)
    • input_audio: Audio object (required)
      • data: Base64 encoded string or URL of audio file (required)
      • type: "base64" or "url" (required)
      • format: Audio file format, supports pcm, wav, mp3, pcm16 (required)
      • sample_rate: Input audio sample rate, supports 8000 and 16000, required when format=pcm16 (optional otherwise)
    • Supported audio formats: WAV, MP3, PCM16
  • Image Content (type: input_image)

    • type: "input_image" (required)
    • input_image: Image object (required)
      • data: Base64 encoded string or URL array of image (required)
      • type: "base64" or "url" (required)
      • image_timesecond: Image time relative to session in seconds, default 0 (optional)
    • Supported image formats: JPEG, PNG, TIFF, BMP, WEBP
  • Video Content (type: input_video)

    • type: "input_video" (required)
    • input_video: Video object (required)
      • data: Base64 encoded string or URL of video (required)
      • type: "base64" or "url" (required)
    • Supported video formats: MP4, AVI, MOV

Assistant Message Format

FieldTypeRequiredDescription
rolestringYesMessage author role, should be assistant in this case
contentarrayYesMessage content, Object content only supports text modality

Example Request (Text Only)

{
  "model": "LongCat-Flash-Omni-2603",
  "messages": [
    {
      "role": "system",
      "content": [
        {
          "type": "text",
          "text": "You are a helpful assistant"
        }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Who are you?"
        }
      ]
    }
  ],
  "sessionId": "13131313121312313",
  "stream": false,
  "topP": 0.1,
  "topK": 1,
  "textRepetitionPenalty": 1,
  "audioRepetitionPenalty": 1.1,
  "inferenceCount": 1,
  "output_modalities":["text","audio"]
}

Example Request (Text + Audio Input)

{
  "model": "LongCat-Flash-Omni-2603",
  "messages": [
    {
      "role": "system",
      "content": [
        {
          "type": "text",
          "text": "You are a helpful assistant"
        }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "type": "input_audio",
          "input_audio":{
            "type" : "url",
            "data" : "https://msstest.sankuai.com/avatar-mgrplatform/BAC009S0764W0495.wav",
            "format" : "wav"
          }
        },
        {
          "type": "text",
          "text": "Understand this audio"
        }
      ]
    }
  ],
  "sessionId": "1231313131",
  "stream": false,
  "topP": 0.1,
  "topK": 1,
  "textRepetitionPenalty": 1,
  "audioRepetitionPenalty": 1.1,
  "inferenceCount": 1,
  "output_modalities":["text","audio"]
}

Example Request (Text + Image Input)

{
  "model": "LongCat-Flash-Omni-2603",
  "messages": [
    {
      "role": "system",
      "content": [
        {
          "type": "text",
          "text": "You are a helpful assistant"
        }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "type": "input_image",
          "input_image":{
            "type" : "url",
            "data" : ["https://msstest.sankuai.com/avatar-mgrplatform/origin_image_113.png"]
          }
        },
        {
          "type": "text",
          "text": "What do you see?"
        }
      ]
    }
  ],
  "sessionId": "1231313131",
  "stream": false,
  "topP": 0.1,
  "topK": 1,
  "textRepetitionPenalty": 1,
  "audioRepetitionPenalty": 1.1,
  "inferenceCount": 1,
  "output_modalities":["text","audio"]
}

Example Request (Text + Video Input)

{
  "model": "LongCat-Flash-Omni-2603",
  "messages": [
    {
      "role": "system",
      "content": [
        {
          "type": "text",
          "text": "You are a helpful assistant"
        }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "type": "input_video",
          "input_video":{
            "type" : "url",
            "data" : "https://msstest.sankuai.com/avatar-mgrplatform/video_sample.mp4"
          }
        },
        {
          "type": "text",
          "text": "What's in this video?"
        }
      ]
    }
  ],
  "sessionId": "1231313131",
  "stream": false,
  "topP": 0.1,
  "topK": 1,
  "textRepetitionPenalty": 1,
  "audioRepetitionPenalty": 1.1,
  "inferenceCount": 1,
  "output_modalities":["text","audio"]
}

Response (Non-streaming)

{
  "created": 1768206959,
  "model": "LongCat-Flash-Omni-2603",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I'm an AI assistant created by Meituan.",
        "audio": "//NExAASIAP..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "completion_tokens": 20,
    "prompt_tokens": 10,
    "total_tokens": 30
  },
  "session_id": "13131313121312313"
}

Response (Streaming)

When stream: true, the response follows Server-Sent Events (SSE) format:

Content-Type: text/event-stream

data: {"created":1768206959,"model":"LongCat-Flash-Omni-2603","choices":[{"index":0,"delta":{"role":"assistant","content":"","audio":null,"type":"response.start","turnId":"turn_6QlZlbVk2o3CB91C6Kw9GA","responseId":"resp_5lrxrIMFkOIJsxHWqGXafb"},"finish_reason":null}],"usage":{"completion_tokens":0,"prompt_tokens":0,"total_tokens":0},"session_id":"13131313121312313"}

data: {"created":1768206959,"model":"LongCat-Flash-Omni-2603","choices":[{"index":1,"delta":{"role":"assistant","content":"I'm an AI assistant","audio":null,"type":"response.text.delta","turnId":"turn_6QlZlbVk2o3CB91C6Kw9GA","responseId":"resp_5lrxrIMFkOIJsxHWqGXafb"},"finish_reason":null}],"usage":{"completion_tokens":5,"prompt_tokens":0,"total_tokens":5},"session_id":"13131313121312313"}

data: {"created":1768206959,"model":"LongCat-Flash-Omni-2603","choices":[{"index":2,"delta":{"role":"assistant","content":" created by Meituan.","audio":null,"type":"response.text.delta","turnId":"turn_6QlZlbVk2o3CB91C6Kw9GA","responseId":"resp_5lrxrIMFkOIJsxHWqGXafb"},"finish_reason":null}],"usage":{"completion_tokens":9,"prompt_tokens":0,"total_tokens":9},"session_id":"13131313121312313"}

data: {"created":1768206959,"model":"LongCat-Flash-Omni-2603","choices":[{"index":3,"delta":{"role":"assistant","content":null,"audio":null,"type":"response.text.done","turnId":"turn_6QlZlbVk2o3CB91C6Kw9GA","responseId":"resp_5lrxrIMFkOIJsxHWqGXafb"},"finish_reason":null}],"usage":{"completion_tokens":9,"prompt_tokens":0,"total_tokens":9},"session_id":"13131313121312313"}

data: {"created":1768206959,"model":"LongCat-Flash-Omni-2603","choices":[{"index":4,"delta":{"role":"assistant","content":null,"audio":"//NExAASIAP...","type":"response.audio.delta","turnId":"turn_6QlZlbVk2o3CB91C6Kw9GA","responseId":"resp_5lrxrIMFkOIJsxHWqGXafb"},"finish_reason":null}],"usage":{"completion_tokens":100,"prompt_tokens":0,"total_tokens":100},"session_id":"13131313121312313"}

data: {"created":1768206959,"model":"LongCat-Flash-Omni-2603","choices":[{"index":5,"delta":{"role":"assistant","content":null,"audio":"//NExAASIAP...","type":"response.audio.delta","turnId":"turn_6QlZlbVk2o3CB91C6Kw9GA","responseId":"resp_5lrxrIMFkOIJsxHWqGXafb"},"finish_reason":null}],"usage":{"completion_tokens":150,"prompt_tokens":0,"total_tokens":150},"session_id":"13131313121312313"}

data: {"created":1768206959,"model":"LongCat-Flash-Omni-2603","choices":[{"index":6,"delta":{"role":"assistant","content":null,"audio":"//NExAASIAP...","type":"response.audio.delta","turnId":"turn_6QlZlbVk2o3CB91C6Kw9GA","responseId":"resp_5lrxrIMFkOIJsxHWqGXafb"},"finish_reason":null}],"usage":{"completion_tokens":200,"prompt_tokens":0,"total_tokens":200},"session_id":"13131313121312313"}

data: {"created":1768206959,"model":"LongCat-Flash-Omni-2603","choices":[{"index":7,"delta":{"role":"assistant","content":null,"audio":"//NExAASIAP...","type":"response.audio.delta","turnId":"turn_6QlZlbVk2o3CB91C6Kw9GA","responseId":"resp_5lrxrIMFkOIJsxHWqGXafb"},"finish_reason":null}],"usage":{"completion_tokens":250,"prompt_tokens":0,"total_tokens":250},"session_id":"13131313121312313"}

data: {"created":1768206959,"model":"LongCat-Flash-Omni-2603","choices":[{"index":8,"delta":{"role":"assistant","content":null,"audio":"//NExAASIAP...","type":"response.audio.delta","turnId":"turn_6QlZlbVk2o3CB91C6Kw9GA","responseId":"resp_5lrxrIMFkOIJsxHWqGXafb"},"finish_reason":"{\"type\": \"abort\", \"message\": \"prev: AT_ST1, cur: ABORT, last_input: {'text_id': -5000000, 'semantic_id': tensor(2, device='cuda:0'), 'req_type': None}, context: {'req_type': 'chat', 'to_abort': True, 'tf_end': False, 'step': 59, 'rank': 0}\"}"}],"usage":{"completion_tokens":295,"prompt_tokens":0,"total_tokens":295},"session_id":"13131313121312313"}

data: {"created":1768206959,"model":"LongCat-Flash-Omni-2603","choices":[{"index":9,"delta":{"role":"assistant","content":null,"audio":null,"type":"response.audio_transcript.done","turnId":"turn_6QlZlbVk2o3CB91C6Kw9GA","responseId":"resp_5lrxrIMFkOIJsxHWqGXafb"},"finish_reason":"{\"type\": \"abort\", \"message\": \"prev: AT_ST1, cur: ABORT, last_input: {'text_id': -5000000, 'semantic_id': tensor(2, device='cuda:0'), 'req_type': None}, context: {'req_type': 'chat', 'to_abort': True, 'tf_end': False, 'step': 59, 'rank': 0}\"}"}],"usage":{"completion_tokens":295,"prompt_tokens":0,"total_tokens":295},"session_id":"13131313121312313"}

data: {"created":1768206959,"model":"LongCat-Flash-Omni-2603","choices":[{"index":10,"delta":{"role":"assistant","content":null,"audio":null,"type":"response.audio.done","turnId":"turn_6QlZlbVk2o3CB91C6Kw9GA","responseId":"resp_5lrxrIMFkOIJsxHWqGXafb"},"finish_reason":"{\"type\": \"abort\", \"message\": \"prev: AT_ST1, cur: ABORT, last_input: {'text_id': -5000000, 'semantic_id': tensor(2, device='cuda:0'), 'req_type': None}, context: {'req_type': 'chat', 'to_abort': True, 'tf_end': False, 'step': 59, 'rank': 0}\"}"}],"usage":{"completion_tokens":295,"prompt_tokens":0,"total_tokens":295},"session_id":"13131313121312313"}

data: [DONE]

Delta Type Description in Streaming Output

delta.typeDescription
textText content delta
audio.deltaAudio data chunk of model response (base64 encoded)
audio.doneModel response audio completion signal
audio_transcript.deltaModel response audio transcription text delta
audio_transcript.doneModel response audio transcription complete, this message contains complete text data
errorException occurred during inference, e.g., downstream decoding failure

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-Flash-Chat",
    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-Flash-Chat",
    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-Flash-Chat",
    "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-Flash-Chat",
    "max_tokens": 1000,
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

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

Last Updated: 3/10/26, 4:00 PM
Contributors: zhuqi09, wb_changzhe02
Prev
Quick Start
Next
Claude Code Configuration