client-and-api
Use Xinference sync and async Python clients, model handles, and HTTP/OpenAI-compatible APIs safely.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- client-and-api
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use Xinference sync and async Python clients, model handles, and HTTP/OpenAI-compatible APIs safely.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md6.4 KB
- 参考文档references/client-workflows.md4.2 KB
- 参考文档references/openai-compatible-api.md4.8 KB
- 参考文档references/troubleshooting.md2.9 KB
- 脚本scripts/make_openai_client_snippets.py6.8 KB
03 SKILL.md 正文
Client and API
Use this sub-skill when a task is about calling a running Xinference service from Python, cURL, the OpenAI SDK, or another HTTP client. It assumes the target model has already been launched and identified by a model UID.
Use this for
Client,AsyncClient,RESTfulClient, andAsyncRESTfulClientusage.launch_model,register_model,list_models,get_model, andterminate_modelclient signatures.- Model handles for chat, text generation, embeddings, rerank, images, audio, video, and flexible model requests.
- Service-root versus
/v1OpenAI-compatible base URL selection. - Streaming response iterators and async iterator handoffs.
- API key headers and endpoint placeholders in examples.
- Request-shape validation, including strict system-message ordering and integer-like replica validation.
Route away when needed
- Service startup, model lifecycle CLI commands, and supervisor/worker cluster
orchestration:
serving-and-cli. - Model family, engine, format, quantization, optional extras, LoRA, or custom
model JSON decisions:
models-and-backends. - Auth database bootstrap, OIDC, admin policy, audit logs, metrics, Web UI, or
deployment hardening:
operations-and-security.
Working pattern
- Confirm the service endpoint root, for example
http://<host>:9997. - Confirm the model UID returned by launch/list operations.
- Pick the API surface:
- Xinference Python client: endpoint root.
- OpenAI-compatible SDK/cURL: endpoint root plus
/v1. - Direct HTTP family endpoints: use the family-specific reference.
- Add
Authorization: Bearer <token-or-api-key>only when auth is enabled. - Keep examples placeholder-only until the user supplies a real endpoint, model UID, and API key policy.
- If a request fails, classify the failure as endpoint/base-url, auth, model-UID, request-shape, streaming, or backend/model-readiness before changing code.
Core rules
- A launched model UID is required for every request family.
- The OpenAI-compatible base URL should end in
/v1; the XinferenceClientconstructor uses the service root. RESTfulClientis a compatibility alias forClient;AsyncRESTfulClientis an alias forAsyncClient.- In this inspected build, the sync
Client.launch_modelexposes virtual-env launch knobs that the async launch signature does not mirror exactly. Checkreferences/api-reference.mdbefore assuming parity. - Treat rerank as a Xinference HTTP/client workflow, not a universal OpenAI SDK helper.
- Do not make live network calls from bundled helper scripts; they render snippets only.
References
- API reference for verified signatures and model handle method notes.
- OpenAI-compatible API for
/v1base URL shape and request-family templates. - Client workflows for sync/async launch, list/get, model handle, streaming, and registration flows.
- Troubleshooting for 401/403, 404, strict message order, replica, streaming, and OCR response issues.
Snippet helper
- make_openai_client_snippets.py renders Python and cURL snippets for chat, generate, embedding, and rerank without contacting a server.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).