Xing4.0-29B-A4B (Algorithm Code: 63650300004) — OpenAI-Compatible API Reference
API protocol: OpenAI Chat Completions
Version: Stable (max_tokens is deprecated; use max_completion_tokens)
1. Endpoint
| Environment |
URL |
| Public endpoint |
https://api-maas.teleai.com.cn/v1/chat/completions |
| OpenAI-compatible base URL |
https://api-maas.teleai.com.cn/v1 |
- Request method:
POST
- Content-Type:
application/json
2. Authentication
Use Bearer token authentication and pass your API key in the request header:
Authorization: Bearer <YOUR_API_KEY>
| Header |
Description |
Authorization |
Bearer ; required |
session-id |
Pass this header for multi-turn conversations. Use a different `session-id` for each session; omit it for other requests. |
traceparent |
W3C Trace Context header for distributed tracing, in the format {version}-{trace-id}-{parent-id}-{flags}; see the table below. |
traceparent field details:
| Field |
Example value |
Description |
version |
00 |
W3C version; default: 00 |
trace-id |
0af7651916cd43dd8448eb211c80319c |
32 hexadecimal characters; a unique ID for the entire trace |
parent-id |
b7ad6b7169203331 |
16 hexadecimal characters; the span ID for the current request |
flags |
01 |
The default 01 is sufficient |
3. Model Capabilities and Limits
3.1 Model Capabilities
| Capability |
Support |
Capability |
Support |
| Input modality |
Text input |
Output modality |
Text output |
| Model playground |
✅ Supported |
Structured Outputs |
✅ Supported |
| Function calling |
✅ Supported |
Reasoning |
✅ Supported |
| Online inference |
✅ Supported |
Batch inference |
❌ Not supported |
| Explicit caching |
❌ Not supported |
Implicit caching |
✅ Supported |
3.2 Model Limits
| Limit |
Value |
Limit |
Value |
| Context window |
256K |
Maximum reasoning length |
128K |
| Maximum input length |
192K |
Maximum input length (reasoning mode) |
64K |
| Maximum output length |
192K |
Maximum output length (reasoning mode) |
64K |
4. Request and Response Bodies
4.1 Request Body
4.1.1 Top-Level Fields
| Field |
Type |
Required |
Description |
model |
string |
Yes |
Corresponding Model Name. Example: Xing4.0-29B-A4B |
messages |
array |
Yes |
Array of messages in conversation order; see 4.1.2 |
frequency_penalty |
number |
No |
Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim; range: -2.0 to 2.0; default: 0 |
logprobs |
boolean |
No |
Whether to return log probabilities for each output token; default: false |
top_logprobs |
integer |
No |
Return the top N most likely alternative tokens at each token position; range: 0 to 20; requires logprobs=true |
max_tokens |
integer |
No |
Deprecated. Use max_completion_tokens instead. |
max_completion_tokens |
integer |
No |
Maximum number of tokens generated for the completion, including reasoning tokens |
n |
integer |
No |
Number of generations to return; default: 1 |
presence_penalty |
number |
No |
Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics; range: -2.0 to 2.0; default: 0 |
repetition_penalty |
number |
No |
Default: 1.05; range: 0 to 2. Controls repetition in generated sequences. Increasing this value can reduce repetition; 1.0 applies no penalty. |
response_format |
object |
No |
An object specifying the format that the model must output; see 4.1.3 |
seed |
integer |
No |
Random seed for reproducible sampling |
stop |
string / array |
No |
Stop sequence |
stream |
boolean |
No |
Whether to stream the response; default: false |
stream_options |
object |
No |
Additional streaming options; see 4.1.4 |
temperature |
number |
No |
Determines the degree of randomness in the response; range: 0 to 2; default: 1.0 |
top_p |
number |
No |
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass; range: 0 to 1; default: 0.95 |
tools |
array |
No |
Array of tool definitions; see 4.1.5 |
tool_choice |
string / object |
No |
Tool selection behavior; see 4.1.6 |
parallel_tool_calls |
boolean |
No |
Whether to allow parallel tool calls; default: true |
chat_template_kwargs |
object |
No |
Reasoning mode options. Reasoning is enabled by default; pass {"enable_thinking": true} to enable it explicitly. |
reasoning_effort |
string |
No |
Reasoning effort; this model does not support it. |
Recommended sampling settings: temperature=1.0 and top_p=0.95.
4.1.2 Messages
Message object (messages[])
| Field |
Type |
Required |
Description |
role |
string |
Yes |
Role: system / user / assistant / tool |
content |
string / array |
Yes |
Message content; supports plain text or an array of content parts |
name |
string |
No |
Participant name, used to distinguish participants with the same role |
tool_calls |
array |
No |
Tool calls made by the assistant (only for assistant messages) |
tool_call_id |
string |
No |
ID of the associated tool call (required for tool messages) |
Message content part (content[])
| Field |
Type |
Required |
Description |
type |
string |
Yes |
Content part type; this model supports only text |
text |
string |
Yes |
Text content |
Tool call object (tool_calls[])
| Field |
Type |
Required |
Description |
id |
string |
Yes |
Tool call ID |
type |
string |
Yes |
Tool type; currently only function is supported |
function |
object |
Yes |
Tool definition |
Function call object (function)
| Field |
Type |
Required |
Description |
arguments |
string |
Yes |
JSON-formatted text |
name |
string |
Yes |
Tool name |
4.1.3 response_format
| Structure |
Description |
{"type":"text"} |
Default text output |
{"type":"json_object"} |
JSON object output (the prompt must contain the word “json”) |
{"type":"json_schema","json_schema":{"name":"...","description":"...","schema":{...},"strict":true}} |
Output constrained by a JSON Schema; currently unsupported |
4.1.4 stream_options
| Field |
Type |
Description |
include_usage |
boolean |
When true, an additional chunk containing usage is returned at the end of the stream |
4.1.5 Tool Definitions (tools[])
| Field |
Type |
Required |
Description |
type |
string |
Yes |
Tool type; currently function |
function |
object |
Yes |
Function definition |
function.name |
string |
Yes |
Function name |
function.description |
string |
No |
Function description |
function.parameters |
object |
No |
Parameter definition in JSON Schema format |
4.1.6 tool_choice
- String:
none (do not call a tool) / auto (let the model choose) / required (the model must call a tool)
- Object:
{"type":"function","function":{"name":"<FUNCTION_NAME>"}} forces a specific function call
4.2 Response Body
4.2.1 Top-Level Fields
| Field |
Type |
Description |
id |
string |
Unique ID for this chat completion |
object |
string |
Fixed value: chat.completion |
created |
integer |
Creation time (Unix timestamp in seconds) |
model |
string |
Model used for this response |
choices |
array |
Array of completion choices |
usage |
object |
Token usage |
Completion choices (choices[])
| Field |
Type |
Description |
index |
integer |
Index of the choice |
message |
object |
Message object |
finish_reason |
string |
Reason generation stopped: stop (natural stop or stop sequence), length (limit reached), tool_calls / function_call (tool call), content_filter (content filtered), null (not yet finished), or abort (aborted). |
logprobs |
object |
Log probabilities of output tokens (returned when logprobs is enabled) |
Message object message
| Field |
Type |
Description |
role |
string |
Role: system / user / assistant / tool |
content |
string |
Text content |
reasoning_content/reasoning |
string |
Reasoning content |
tool_calls[] |
object |
{id, type:function, function:{name, arguments}}; arguments is a JSON-formatted string |
Token usage usage
| Field |
Type |
Description |
prompt_tokens |
integer |
Number of prompt tokens |
completion_tokens |
integer |
Number of completion tokens |
total_tokens |
integer |
Total number of tokens |
prompt_tokens_details.cached_tokens |
integer |
Number of cached prompt tokens |
4.2.2 Streaming (SSE) Response Fields
| Field |
Type |
Description |
id |
string |
Unique ID for this chat completion |
object |
string |
Fixed value: chat.completion.chunk |
created |
integer |
Creation time (Unix timestamp in seconds) |
model |
string |
Model used for this response |
choices |
array |
Array of completion choices |
choices[].index |
integer |
Index of the choice |
choices[].delta |
object |
Same fields as choices[].message in the response body |
choices[].finish_reason |
string |
Reason generation stopped: stop (natural stop or stop sequence), length (limit reached), tool_calls / function_call (tool call), content_filter (content filtered), null (not yet finished), or abort (aborted). |
choices[].logprobs |
object |
Log probabilities of output tokens (returned when logprobs is enabled) |
usage |
object |
Token usage |
5. Request Examples
5.1 curl
curl --location 'https://api-maas.teleai.com.cn/v1/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--data '{
"model": "Xing4.0-29B-A4B",
"messages": [
{ "role": "user", "content": "Hello, introduce yourself in one sentence." }
],
"stream": true
}'
5.2 Python
import requests
url = "https://api-maas.teleai.com.cn/v1/chat/completions"
api_key = "<YOUR_API_KEY>"
payload = {
"model": "Xing4.0-29B-A4B",
"messages": [{"role": "user", "content": "Hello, introduce yourself in one sentence."}],
"stream": True
}
resp = requests.post(
url,
headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}",
},
json=payload,
stream=True,
)
# Parse the SSE stream
for line in resp.iter_lines(decode_unicode=True):
if line and line.startswith("data:"):
data = line[len("data:"):].strip()
if data == "[DONE]":
break
print(data)
5.3 Java (with OkHttp and Jackson)
import okhttp3.*;
import com.fasterxml.jackson.databind.ObjectMapper;
public class ChatCompletionsExample {
public static void main(String[] args) throws Exception {
String url = "https://api-maas.teleai.com.cn/v1/chat/completions";
String apiKey = "<YOUR_API_KEY>";
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(java.util.Map.of(
"model", "Xing4.0-29B-A4B",
"messages", java.util.List.of(
java.util.Map.of("role", "user", "content", "Hello, introduce yourself in one sentence.")
),
"stream", true
));
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer " + apiKey)
.post(RequestBody.create(json, MediaType.get("application/json")))
.build();
try (Response response = client.newCall(request).execute()) {
// Non-streaming: print the response body directly
System.out.println(response.body().string());
// Streaming: read SSE lines from ResponseBody.source() until [DONE]
}
}
}