Skip to main content

llm-api-adapter-qwen

Official Model Studio Frankfurt/Global support for Qwen in llm-api-adapter. The package uses the Anthropic-compatible Messages API directly.

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)

Qwen 0.1.0 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 and capabilities

The package deliberately exposes fixed model IDs, not moving aliases: qwen3.8-max, qwen3.8-flash, qwen3.7-plus, and qwen3.7-flash.

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.

Cost fields use Frankfurt Global standard CNY text rates. They exclude cached, batch, promotional, and negotiated pricing.

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.

PDF input

Qwen 0.1.0 supports images, but not PDFs. DocumentPart URLs and bytes are rejected before any HTTP request:

Qwen does not support DocumentPart; PDF and OCR are unavailable in Qwen 0.1.0.

The package does not make a partial PDF/OCR request or upload document bytes.

See the main llm-api-adapter README for the shared API contract and examples.

Metadata

Release files for llm-api-adapter-qwen 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-api-adapter-qwen 0.1.1
File Size Uploaded Provenance Actions
llm_api_adapter_qwen-0.1.1.tar.gz 20.7 kB Without provenance Details for llm_api_adapter_qwen-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llm-api-adapter-qwen 0.1.1
File Interpreter ABI Platform Actions
llm_api_adapter_qwen-0.1.1-py3-none-any.whl Python 3 none any Details for llm_api_adapter_qwen-0.1.1-py3-none-any.whl

Total release size: 37.3 kB

Release files / llm_api_adapter_qwen-0.1.1.tar.gz

Download URL llm_api_adapter_qwen-0.1.1.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4b1f057557a1230499526c73e5ffc7c33df2382f7735b3ae3992c5c262609ee5
BLAKE2b-256 checksum
How to use checksums
e90223e98b1ea9d93d5fdff78b693b0ad29ccdc043bb79ed6f84497394ae069c
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.1-py3-none-any.whl

Download URL llm_api_adapter_qwen-0.1.1-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7e044a179dc570d34d97bb125b12e08f575c578fddd8c35bfc75c4f7c2b0c67
BLAKE2b-256 checksum
How to use checksums
16e5c1bd8ce27e4d710857960a4006042e60b9d55966defae52f98b7236b1d61
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.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page