Chat and Voice
OpenAI-compatible text chat
Use POST /v1/chat/completions with your ModelGo API key. Supported models: enj-1-uncensored and chat-fast. The old qwen-character model is no longer offered. The API supports text Chat Completions, not every OpenAI feature.
curl https://api.modelgo.moneygo.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{"model":"chat-fast","messages":[{"role":"user","content":"Hello!"}],"max_tokens":256}'{
"id": "chatcmpl_example",
"object": "chat.completion",
"created": 1792540800,
"model": "chat-fast",
"choices": [{"index":0,"message":{"role":"assistant","content":"Hello!","refusal":null},"logprobs":null,"finish_reason":"stop"}],
"usage": {"prompt_tokens":10,"completion_tokens":3,"total_tokens":13}
}Models and prices
GET /v1/models: standard model list; only configured, priced models are listed.GET /v1/chat/catalog: both model IDs, availability, input/output prices in credits per million tokens. A null price means pricing is not configured and calls are disabled.- The public Pricing page shows the same sale prices. Input and output prices are configured separately by the platform; they are not a per-request fee.
Parameters
Send the full conversation in messages. No server history or default persona is injected into this endpoint.
| Parameter | Supported values |
|---|---|
| model | enj-1-uncensored, chat-fast |
| messages | 1–1000 messages; system, developer, user, assistant roles |
| content | String or array of text parts: [{"type":"text","text":"Hello"}] |
| stream | Boolean, default false |
| temperature / top_p | 0–2 / 0–1 |
| max_tokens or max_completion_tokens | Integer 1–8192, mutually exclusive; default 2048 |
| stop | String or 1–4 strings |
| presence_penalty / frequency_penalty | −2–2 |
| seed | Safe integer |
| n | Only 1 |
| stream_options | {"include_usage":true}, only with stream=true |
Unsupported fields are rejected: tools/function calls, image/audio input, structured output, log probabilities, multiple choices and the Responses API. Sampling behavior depends on the model. Large requests and upstream context overflows may be rejected.
SDK example and streaming
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["MODELGO_API_KEY"],
base_url="https://api.modelgo.moneygo.ai/v1",
max_retries=0,
)
stream = client.chat.completions.create(
model="chat-fast",
messages=[{"role": "user", "content": "Hello!"}],
max_tokens=256,
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="", flush=True)
if chunk.usage:
print(chunk.usage)Streaming uses data-only SSE, ending in data: [DONE]. Read choices[0].delta.content. With include_usage=true, a final chunk has choices: [] and usage; other chunks have usage=null. Otherwise usage is omitted from streamed chunks, but billing still uses it. All chunks share a completion ID.
Errors before streaming use HTTP JSON. After streaming starts an error frame terminates without [DONE]; partial text is not proof of completion. Cancellation before settlement releases the reservation; cancellation after successful settlement does not reverse the charge. Non-streaming upstream timeout is 60 seconds; streaming has a 90-second connection/inactivity timeout and a 180-second total cap.
Token billing
credits = (prompt_tokens × inputPrice + completion_tokens × outputPrice) / 1,000,000
The sum is rounded up once to 8 decimal places. Input includes all supplied history and system instructions. Cached input uses the input rate; reasoning included in completion_tokens is not charged again. Only validated upstream usage is billed; no text-length estimate or per-reply fallback is used.
Before the call, a conservative credit reservation covers input and the requested output limit. Reduce max_tokens if you need a smaller hold. Unused credits are released. Failure, missing/invalid usage or an incomplete stream releases the hold. Crash-abandoned holds are recovered after 10 minutes. Wallet ledger notes include completion ID, model, input/output counts. Holds and refunds are not additional charges. Chat is not an image/video generation task.
Requests are not idempotent; retries can generate another paid completion.
Errors
{"error":{"message":"...","type":"invalid_request_error","param":null,"code":"invalid_request"}}400 invalid or unsupported parameters; 401 invalid key; 402 insufficient reservation balance; 429 rate limit; 503 unavailable/unconfigured model, upstream failure or invalid usage. Standard API key/IP/rate-limit rules apply.
Existing conversations and voice
Legacy /v1/chat/messages and conversation management routes remain for existing clients, but now use the two new models and token billing. Supply model to select one. Existing messages are preserved; old conversations use the configured default model unless a new model has been saved. New integrations should use Chat Completions.
Playground keeps server-side history and persona settings; these count as input tokens. Model selection is in Chat settings.
Transcription remains unchanged: POST /v1/chat/transcribe accepts audio data URI/base64 (10 MB maximum).
Text-to-speech (TTS)
Supported models: Speech Light (speech-light), Speech Pro (speech-pro), and Speech Expressive (speech-expressive). Legacy Qwen TTS and voices such as Cherry are no longer available. Authenticate with your ModelGo API key, not an upstream key.
GET /v1/speech/catalog returns speechModels, voices, and defaultVoice. Use a complete voices[].id, not a display name. Its modelId identifies the speech model. Voices are callable only when available upstream and priced locally; price=-1 means unconfigured. Administrators can set a default voice; Playground users can select a speech model and voice in Chat settings.
OpenAI SDK-compatible endpoint
POST /v1/audio/speech returns a binary MP3 audio stream. Supported fields: model, input, voice, and optional response_format="mp3". The model must match the voice. Other formats, speed, instructions, and the wider OpenAI Audio API are not supported.
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["MODELGO_API_KEY"], base_url="https://api.modelgo.moneygo.ai/v1")
# Check /v1/speech/catalog for voice availability first.
with client.audio.speech.with_streaming_response.create(
model="speech-light", voice="speech-light:af_alloy",
input="Hello, welcome to ModelGo.", response_format="mp3",
) as response:
response.stream_to_file("speech.mp3")JSON and streaming endpoint
POST /v1/chat/speech accepts { "text":"Hello!", "voice":"speech-light:af_alloy" }. Omitting voice uses the local available default. The response contains {audio, voice, billing}. Audio is an MP3 data URI. Billing contains local credits, model, characters, price, unit="1000_characters", and character_counting="utf16_code_units".
Add "stream":true to receive continuous audio/mpeg bytes, not SSE or JSON:
curl --fail --no-buffer https://api.modelgo.moneygo.ai/v1/chat/speech \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{"text":"Hello!","voice":"speech-light:af_alloy","stream":true}' \
--output speech.mp3Billing and limits
- Maximum input: 2,000 UTF-16 units. Ordinary Chinese/Latin characters count as one; 😀 counts as two. Settlement uses upstream's actual count after removing formatting/action descriptions, not requests or audio seconds.
- Cost = billable characters × local price per 1,000 characters ÷ 1,000, rounded up once to eight decimal places. All three models have independent administrator-configured prices, separate from text-chat charges.
- Raw input length reserves credits before synthesis; valid upstream usage settles the actual cost and releases unused credits. Missing/invalid usage, failure, or disconnect before settlement releases the hold. Disconnect after settlement does not reverse a successful charge.
- Insufficient balance returns 402; unknown/mismatched voices or models return 400; upstream unavailability returns 503. A failure after streaming starts terminates the connection. Discard incomplete audio and check wallet history: HTTP 200 or the first chunk alone does not confirm success.
- Ledger notes record model, characters, and price per 1,000 units. Do not add hold and charge together. Replaying obtained audio is free; calling synthesis again incurs another charge.
- Catalog and Pricing show ModelGo selling prices, never upstream credit prices. This billing replaces legacy free Qwen read-aloud.
