llm-api-adapter-qwen
An optional Qwen organization package for LLM API Adapter, a Python SDK with one shared interface for calling LLM APIs.
Uses Model Studio's Frankfurt Global deployment through its Anthropic-compatible Messages API.
Installation
Install through the Core package extra:
pip install "llm-api-adapter[qwen]"
Direct installation is also supported when Core is managed separately:
pip install llm-api-adapter-qwen
Async requests need HTTPX:
pip install "llm-api-adapter[qwen,async]"
Synchronous requests use requests by default. To opt into HTTPX for sync
chat() and stream_chat(), install "llm-api-adapter[qwen,httpx]" and pass
transport="httpx".
Quick start
import os
from llm_api_adapter.models.messages.chat_message import UserMessage
from llm_api_adapter.universal_adapter import UniversalLLMAPIAdapter
adapter = UniversalLLMAPIAdapter(
organization="qwen",
model="qwen3.8-max",
api_key=os.environ["QWEN_API_KEY"],
)
response = adapter.chat(
messages=[UserMessage("Explain retrieval-augmented generation.")],
max_tokens=128,
workspace_id=os.environ["QWEN_WORKSPACE_ID"],
)
print(response.content)
The package supports only Model Studio's Frankfurt Global deployment. Pass the
required workspace_id explicitly to every chat, stream_chat, achat,
and astream_chat call; it is never read from an environment variable. The
package uses:
https://{workspace_id}.eu-central-1.maas.aliyuncs.com/apps/anthropic/v1/messages
Supported models
qwen3.8-maxqwen3.8-flashqwen3.7-plusqwen3.7-flash
Capabilities
| Capability | Supported models |
|---|---|
| Text chat, sync/async streaming, application function tools, JSON Schema/Pydantic output, and image URLs or bytes | All four models |
reasoning_level |
Qwen 3.8: categorical effort; Qwen 3.7: numeric thinking budget |
All four models default to hybrid thinking. Set reasoning_level="none" to
disable thinking, or capture_reasoning=True to receive provider-emitted
reasoning separately from visible text. max_tokens must be a positive integer
and limits generated output; it is separate from Qwen 3.7's thinking budget.
With thinking enabled, Model Studio's reported usage.output_tokens can also
include thinking tokens, so it can exceed max_tokens even when the visible
answer respects that output limit.
Qwen permits tool_choice="auto" and "none" in thinking mode, but not a
forced "any" or named tool. For a forced tool call, the adapter automatically
disables thinking and issues a UserWarning; pass reasoning_level="none" to
make that choice explicit without a warning.
Both forced tool-choice modes are declared pass exceptions: the adapter
handles the provider restriction while preserving the tool-call contract.
previous_response is accepted but ignored; supply complete messages
history, including assistant tool calls and tool results, on each turn.
Exact rules and exceptions are recorded in the Qwen registry.
PDF input
The package rejects DocumentPart URLs and bytes before any HTTP request.
It does not upload documents or run OCR.
Automatic cache usage and pricing
Model Studio's Messages usage reports ordinary input_tokens separately from
cache_read_input_tokens. When both counts are present, the adapter adds them
to normalize total Usage.input_tokens and exposes cache reads as
Usage.cached_tokens. The registry tier is selected from this total, then
ordinary and cached input use their own Frankfurt Global CNY rates.
No automatic cache-write component is priced, and cache_write_tokens remains
None. An omitted cache-read split leaves cost_input and cost_total unknown;
known output cost can remain available. Opt-in caching, TTLs, storage, batch,
promotional, and negotiated rates are excluded. See the shared
usage and pricing guide.
See the main llm-api-adapter README for the shared API contract and examples.
Metadata
Release files for llm-api-adapter-qwen 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm_api_adapter_qwen-0.1.2.tar.gz | 22.7 kB | Without provenance | Details for llm_api_adapter_qwen-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_api_adapter_qwen-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for llm_api_adapter_qwen-0.1.2-py3-none-any.whl |
Total release size: 40.6 kB
Release files / llm_api_adapter_qwen-0.1.2.tar.gz
| Download URL | llm_api_adapter_qwen-0.1.2.tar.gz |
|---|---|
| Size | 22.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d916b6e42df9c7a4a6aaa765eab5821a28978df21cebdb041b3d304a504a619c
|
|
BLAKE2b-256 checksum How to use checksums |
09b0e79860d856c8a41a98c929f49dc6f6046766a1366c1ca655bf539a0c0e6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / llm_api_adapter_qwen-0.1.2-py3-none-any.whl
| Download URL | llm_api_adapter_qwen-0.1.2-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb53b96aa3e06f05145ca8724cf981d0b328b24f974becfb410e9487d1b7e9a7
|
|
BLAKE2b-256 checksum How to use checksums |
910aac8fd75e3ead6968771c872a2224bcad89d61a7579f45228e11dc104b725
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for llm-api-adapter-qwen 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.