EN ▾
Get API key

Quickstart for Cosyvoice pipelines

Integrate CosyVoice's uncensored text API into your creative pipeline using standard OpenAI SDKs. This quickstart covers configuration, streaming, structured output, and tool use for audio and video workflows.

Configure Base URL and Key

Start by obtaining an API key from the Get API key page. You can sign in with Google or use an email and password. The key is displayed immediately and is the only active key for your account; generating a new one replaces the previous key.

Set your base URL to https://api.cosyvoice.top/v1. Use the model ID uncensored for all requests. This endpoint is compatible with any OpenAI-compatible client, allowing you to swap your base URL without changing your application code.

Basic Text Completion Request

Send a standard POST /v1/chat/completions request to generate text. The API accepts messages arrays and returns raw text output. This is ideal for prompt engineering, script generation, or post-processing in your pipeline.

Ensure your payload includes the model identifier and your authentication header. The API does not perform image, audio, or video generation itself; it provides the text layer that powers those workflows.

curl

Python SDK Integration

Use the official OpenAI Python SDK to interact with the API. Initialize the client with your API key and the CosyVoice base URL. This approach allows you to leverage existing Python codebases with minimal changes.

Pass your messages and set the model to uncensored. The SDK handles the HTTP requests and parses the JSON responses automatically. This method is recommended for server-side integration in audio or video generation pipelines.

python

Node SDK Usage

For JavaScript or TypeScript environments, use the OpenAI Node SDK. Configure the base URL and API key during initialization. This enables seamless integration into web applications or Node.js services that require text completion.

Call the chat.completions.create() method with the uncensored model. The SDK manages the connection and response parsing, allowing you to focus on integrating the text output into your larger creative pipeline.

node

Streaming Responses with SSE

Enable streaming by setting stream: true in your request. The API returns Server-Sent Events (SSE), delivering tokens in real-time. This is useful for progressive text display or real-time processing in audio pipelines.

Each chunk contains partial text. The final chunk includes token usage statistics. Streaming reduces perceived latency and allows your application to begin processing text before the full response is generated.

stream

Rate Limits, Errors, and Context

The API enforces a limit of 300 requests per minute per key and allows 8 concurrent requests. The maximum request body size is 8 MB. The context window is 100,000 tokens (prompt + completion), with no separate output cap.

Handle errors appropriately: 401 indicates an invalid key, 402 means insufficient credit, and 429 signals rate limiting. Credit is prepaid and never expires. Errors and refusals do not consume tokens, ensuring you only pay for successful completions.

cURL

curl https://api.cosyvoice.top/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Write a blunt product review of a cheap VPN."}]
  }'

Python

from openai import OpenAI

client = OpenAI(base_url="https://api.cosyvoice.top/v1", api_key="YOUR_KEY")

resp = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)

Node.js

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.cosyvoice.top/v1", apiKey: process.env.API_KEY });

const resp = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);

Streaming

stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Tell the story in second person."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Specs at a glance

Use this table to decide whether the API fits your project before you buy credit.

ItemValue
API formatOpenAI Chat Completions schema; official openai SDKs work unchanged
Model IDuncensored
AuthenticationAuthorization: Bearer YOUR_KEY
EndpointsPOST /v1/chat/completions · GET /v1/models
Base URLhttps://api.cosyvoice.top/v1
Max outputup to the rest of the 100,000-token window; max_tokens optional (no separate cap)
Context window100,000 tokens (prompt + completion together)
Sampling parameterstemperature, top_p, stop, seed and the two penalties are passed through
JSON modeJSON object mode via response_format json_object
Function callingSupported: tools + tool_choice, tool_calls in the reply (streamed too), tool results as role: tool messages
SSE streamingYes — server-sent events; the last chunk carries token usage
Rate limit300 requests per minute per key
Parallel requestsup to 8 in parallel per key
Response headersX-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency
Request sizeup to 8 MB per request
Trial credit$0.50 of credit valid 7 days, no card needed · Trial key: 2 parallel requests, 60 req/min; full limits (8 and 300) after first top-up
Paymentcrypto: USDT on TRON or USDC on Base, $20–$500, any whole sum
How you paypay as you go from prepaid credit; nothing is charged for failed or refused requests
Token prices$0.15 per 1M input tokens · $0.50 per 1M output tokens
Subscriptionpaid credit never expires, no subscription
Bonus credit+5% from $50, +10% from $100, +15% from $200
Keysone active key per account; a new key replaces the old one
Content policyadult content allowed; sexual content involving minors is refused
Sign-inGoogle or e-mail and password

Error reference

Errors come back as JSON with a stable type; failed and refused requests are not billed.

StatusTypeReason
400bad_requestinvalid JSON, empty messages, bad parameter, or a prompt longer than the window — fix and resend
401missing_key · invalid_key · key_revokedcheck the Authorization header or use your current key
402no_creditout of credit; add credit and retry
403content_blockedrefused by the content policy
404not_foundunknown endpoint
413request_too_largebody over 8 MB
429rate_limited · concurrencyover 300/min or 8 parallel — back off and retry
503upstream_busymodel busy — retry in a few seconds

Questions and answers

How do I top up my API credit?

You can top up by crypto (USDT on TRC20, USDC on Base). Minimum top-up is $20, and maximum is $500. Bonuses are applied at $50 (+5%), $100 (+10%), and $200 (+15%). Credit never expires.

What is the context window size?

The context window is 100,000 tokens, combining both the prompt and the completion. There is no separate output cap, and if you do not specify max_tokens, the response can run to the end of the window.

Is there a free trial available?

Yes, new users get $0.50 of trial credit valid for 7 days. Claim this credit with one click on your API key page. No credit card is needed to start. The trial is one per person and requires signup via Google or email.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key