LLM API Guide

Xing4.0 29B A4B API: How to Access It

Call xingchen-agi/xing4.0-29b-a4b:free on OpenRouter via OpenAI or Anthropic Messages endpoints, or self-host the 29B MoE API with vLLM and SGLang plugins.

An isometric API request travels through a router toward a server, with a second branch ending at an error checkpoint.
Illustration, AI-generated

Summary

  1. Use model ID xingchen-agi/xing4.0-29b-a4b:free on OpenRouter for $0/1M input and output tokens (as of 2026-10-29) across OpenAI Chat Completions, Responses.
  2. Install the required out-of-tree xing4-vllm-plugin or xing4-sglang-plugin (or pull the official Quay container images) before self-hosting.
  3. Keep thinking mode enabled and lower temperature to 0.8 for coding and agent workloads.

If you are searching for xingchen-agi/xing4.0-29b-a4b:free, that string is the exact model ID for calling China Telecom's (TeleAI) open-weight Xing4.0-29B-A4B model through OpenRouter's free tier. You have two ways to access its API right now: send requests to OpenRouter's hosted endpoints at $0 per million tokens (as of 2026-10-29), or pull the Apache 2.0 weights and run your own OpenAI-compatible /v1 server with vLLM, SGLang, or KTransformers.

Access Method Endpoint / Base URL Model Identifier Cost (as of 2026-10-29) / Hardware Needed
OpenRouter (OpenAI Chat) https://openrouter.ai/api/v1/chat/completions xingchen-agi/xing4.0-29b-a4b:free $0 / 1M in & out (rate-limited)
OpenRouter (Anthropic Format) https://openrouter.ai/api/v1/messages xingchen-agi/xing4.0-29b-a4b:free $0 / 1M in & out (rate-limited)
OpenRouter (Responses API) https://openrouter.ai/api/v1/responses xingchen-agi/xing4.0-29b-a4b:free $0 / 1M in & out (rate-limited)
Self-Hosted (vLLM / SGLang) http://localhost:8000/v1 Xing4.0-29B-A4B ~58 GB VRAM (BF16) or FP8 / 2x GPUs
Self-Hosted (KTransformers) http://localhost:30000/v1 Xing4.0-29B-A4B Single 24 GB GPU + system RAM offload
On this page

Calling xingchen-agi/xing4.0-29b-a4b:free on OpenRouter

The fastest way to test the model is through OpenRouter's hosted page. Behind the scenes, OpenRouter forwards requests for this model directly to Phala without extra routing hops. The endpoint exposes the full 262,144-token (256K) context window and a 235,929-token maximum output limit, delivering a median latency around 1.22 seconds and roughly 37 tokens per second.

OpenAI Chat Completions and Responses API

If your codebase already uses the official OpenAI SDK, you only need to swap the base_url and pass your OpenRouter key (sk-or-v1-...). If you haven't configured custom endpoints in the client before, see my guide on changing the OpenAI Python SDK base_url and API key.

python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://openrouter.ai/api/v1",
    api_key=os.environ["OPENROUTER_API_KEY"],
)

response = client.chat.completions.create(
    model="xingchen-agi/xing4.0-29b-a4b:free",
    messages=[
        {"role": "user", "content": "Write a Python script to parse nginx access logs by status code."}
    ],
    temperature=0.8,
    top_p=0.95,
    extra_body={
        "repetition_penalty": 1.05,
        "reasoning": {"effort": "high"}
    }
)

print(response.choices[0].message.content)

OpenRouter also supports the newer OpenAI Responses API format for this model at POST https://openrouter.ai/api/v1/responses using the same bearer token and model ID.

Anthropic Messages API Format (POST /api/v1/messages)

One detail missing from most setup guides is that OpenRouter also serves xingchen-agi/xing4.0-29b-a4b:free over the native Anthropic Messages API protocol at POST https://openrouter.ai/api/v1/messages.

Because TeleAI built Xing4.0-29B-A4B specifically for agentic tool use and terminal coding—where it scores 57.50 on Terminal-Bench 2.1 and 75.00 on SWE-bench Verified—having a native /v1/messages endpoint means you can hook it directly into Anthropic-based agent harnesses or Claude Code without running a translation proxy. If you are also weighing another model on OpenRouter, see access and pricing for Gemini 4 Carbon.

bash
curl https://openrouter.ai/api/v1/messages \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "xingchen-agi/xing4.0-29b-a4b:free",
    "max_tokens": 4096,
    "temperature": 0.8,
    "messages": [
      {
        "role": "user",
        "content": "Inspect the current directory structure and list any failing pytest files."
      }
    ]
  }'

When you wire this endpoint into an agent CLI, keep an eye on your request payloads. If your client sends unsupported thinking headers or exceeds the 262,144-token window, you will get a 400 rejection; I broke down how to isolate those in Claude Code API Error 400: How Do I Fix Each Message?.

What the :free Suffix Actually Means in Production

Both input and output tokens on xingchen-agi/xing4.0-29b-a4b:free cost $0, and you do not need a monthly subscription. However, free endpoints on OpenRouter enforce strict per-minute and per-day rate limits, and your account status affects how quickly you hit 429 Too Many Requests errors (I covered how credit balances affect account tiers in How Much Does OpenRouter Cost, and Is It Expensive?).

If you are running automated agent loops, you should also account for parsing failures. On the hosted Phala node, tool-calling requests have an error rate of roughly 3.20%, and structured JSON outputs (response_format) fail validation about 6.38% of the time. Always wrap your calls in retry logic or pass a fallback model array in your OpenRouter request body so a 429 or malformed tool call doesn't kill a multi-step run.

Tuning Reasoning Mode and Sampling Parameters

Xing4.0-29B-A4B enables chain-of-thought reasoning by default. When I tested it with thinking turned off, its one-shot output quality dropped noticeably behind Qwen3.6-35B-A3B. With thinking turned on, it holds its own on complex multi-step coding and agent planning. Unless you are building a low-latency classifier where extra reasoning tokens break your time budget, leave thinking enabled.

If you do need to suppress the thinking trace so a basic client doesn't render raw <think> tags in the final answer, the parameter depends on where you call the API:

  • On OpenRouter: Pass "reasoning": {"exclude": True} inside your JSON body (or extra_body in the Python SDK) to strip reasoning tokens from the returned message, or set "reasoning": {"max_tokens": 0} to disable them.
  • On Self-Hosted vLLM or SGLang: Pass extra_body={"chat_template_kwargs": {"enable_thinking": False}} in your OpenAI client call.

TeleAI also specifies two distinct sampling profiles in the official GitHub documentation rather than using a single default:

  • Coding and agentic tool-calling tasks: Set temperature to 0.8, top_p to 0.95, and repetition_penalty to 1.05.
  • General chat and complex reasoning: Raise temperature to 1.0, while keeping top_p at 0.95 and repetition_penalty at 1.05.

Self-Hosting the API with vLLM or SGLang

If you want to avoid OpenRouter's free-tier rate limits, you can host the model yourself. Even though Xing4.0-29B-A4B was trained on Huawei Ascend 910C NPUs using MindSpore, the weights released on Hugging Face (XingChen-AGI/Xing4.0-29B-A4B and XingChen-AGI/Xing4.0-29B-A4B-FP8) run on standard NVIDIA GPUs.

Hard Prerequisite: Install the Out-of-Tree Architecture Plugins

Do not just pull a standard vLLM or SGLang environment and run vllm serve. Mainline vLLM and SGLang have not merged the xing4_0 model architecture into their stable releases yet. Because the model combines Multi-Head Latent Attention (MLA), mHC, and Multi-Token Prediction (MTP), running an unmodified server throws a KeyError: 'xing4_0' or an unrecognized architecture crash immediately on startup.

Before launching the API server, you must either install TeleAI's dedicated out-of-tree plugin for your framework or run their pre-built Quay container images:

  1. For vLLM: Install XingChen-AGI/xing4-vllm-plugin via pip install git+https://github.com/XingChen-AGI/xing4-vllm-plugin.git, or pull the pre-built image quay.io/xingchen-agi/xingchen-inference-vllm:v0.29.1rc1-xing4_0.
  2. For SGLang: Install XingChen-AGI/xing4-sglang-plugin via pip install git+https://github.com/XingChen-AGI/xing4-sglang-plugin.git, or pull quay.io/xingchen-agi/xingchen-inference-sglang:v0.5.20.rc1-xing4_0.

If you are building from source rather than using Docker, the SGLang plugin setup is currently cleaner to compile than the vLLM branch.

Launching the vLLM OpenAI-Compatible Server

Once the xing4-vllm-plugin is installed, start the server with --trust-remote-code and the dedicated xing4_0 parsers for reasoning and tool calls:

bash
vllm serve /path/to/Xing4.0-29B-A4B \
    --host 0.0.0.0 \
    --port 8000 \
    --served-model-name Xing4.0-29B-A4B \
    --tensor-parallel-size 2 \
    --trust-remote-code \
    --max-model-len 262144 \
    --gpu-memory-utilization 0.90 \
    --max-num-seqs 4 \
    --enable-auto-tool-choice \
    --reasoning-parser xing4_0 \
    --tool-call-parser xing4_0 \
    --speculative-config '{"method":"mtp", "num_speculative_tokens": 1}'

Do not skip --reasoning-parser xing4_0 or --tool-call-parser xing4_0. Without those two flags, vLLM dumps raw XML/thinking strings into message.content instead of populating the structured tool_calls and reasoning fields in the API response. Notice also that --max-num-seqs is capped at 4; at the full 262,144 context length, leaving concurrency unbounded will exhaust KV cache and trigger a CUDA out-of-memory crash.

Launching the SGLang Server

With xing4-sglang-plugin installed, the equivalent SGLang command uses EAGLE speculative decoding and the same xing4_0 parsers:

bash
sglang serve --model-path /path/to/Xing4.0-29B-A4B \
   --trust-remote-code \
   --host 0.0.0.0 \
   --port 8000 \
   --served-model-name Xing4.0-29B-A4B \
   --tp-size 2 \
   --context-length 262144 \
   --mem-fraction-static 0.90 \
   --max-running-requests 4 \
   --reasoning-parser xing4_0 \
   --tool-call-parser xing4_0 \
   --speculative-algorithm EAGLE

Both servers listen on http://localhost:8000/v1 and accept standard OpenAI SDK requests with model="Xing4.0-29B-A4B".

Hardware Sizing, KTransformers, and the llama.cpp Trap

Because Xing4.0-29B-A4B is a sparse Mixture-of-Experts model—64 routed experts and 1 shared expert across 40 layers, activating only 4 experts (4B parameters) per token—inference compute is light, but memory capacity is still dictated by the full 29B parameter count.

In unquantized BF16, the model weights alone occupy roughly 58 GB of VRAM before allocating any KV cache. A single 80 GB H100 or A100 can hold the BF16 model and reach the 256K context limit for a single concurrent request, while two 80 GB cards (--tp-size 2) give you comfortable headroom for 256K–512K context workloads.

If you only have a single 24 GB GPU, you can still serve a local API by running KTransformers inside SGLang. Because only 4 out of 64 routed experts fire on any given token, KTransformers keeps 24 hot experts and the MLA attention layers in GPU VRAM while offloading the remaining cold experts to system RAM:

bash
python -m sglang.launch_server \
  --host 0.0.0.0 \
  --port 30000 \
  --model-path /path/to/Xing4.0-29B-A4B \
  --served-model-name Xing4.0-29B-A4B \
  --tensor-parallel-size 1 \
  --trust-remote-code \
  --attention-backend triton \
  --kt-weight-path /path/to/Xing4.0-29B-A4B \
  --kt-method BF16 \
  --kt-cpuinfer 50 \
  --kt-threadpool-count 2 \
  --kt-num-gpu-experts 24 \
  --mem-fraction-static 0.9 \
  --chunked-prefill-size 512 \
  --max-total-tokens 65536 \
  --tool-call-parser xing4_0 \
  --reasoning-parser xing4_0

What about running the official GGUF weights (XingChen-AGI/Xing4.0-29B-A4B-GGUF) in llama.cpp? Be careful here: mainline llama.cpp does not support Xing4.0 yet. The upstream pull request is still blocked on custom xing_hc operators, so a standard llama-server binary will refuse to load the GGUF file. To run GGUF right now, you have to compile a custom community fork (shuxiaoqiong/xing4_0-llama-pc-deploy) and pass -ngl 999 so layers don't spill onto CPU—and even on a 24 GB card with IQ4_NL quantization, generation sits around 29.6 tokens/s with a 0.48 MTP draft acceptance rate. Until upstream llama.cpp merges native support, either use KTransformers for single-GPU local serving or stick to the free xingchen-agi/xing4.0-29b-a4b:free endpoint on OpenRouter.

Sources and checks

  1. Xing4.0-29B-A4B
  2. OpenRouter's hosted page
  3. official GitHub documentation
  4. XingChen-AGI/xing4-vllm-plugin
  5. XingChen-AGI/xing4-sglang-plugin
  6. XingChen-AGI/Xing4.0-29B-A4B-GGUF