Skip to main content
Use Qwen models with Hypertic agent.

Installation

Install the OpenAI package (Qwen uses OpenAI-compatible API):
pip install hypertic[openai]

Setup

Set your Qwen API key as an environment variable:
export QWEN_API_KEY=...

Initialize Model

Create a Qwen model instance:
from hypertic.models import Qwen
import os

model = Qwen(
    api_key=os.getenv("QWEN_API_KEY"),
    model="qwen-turbo",
)

Use with Agent

Pass the model to your agent:
from hypertic.agents import Agent
from hypertic.models import Qwen
import os

model = Qwen(
    api_key=os.getenv("QWEN_API_KEY"),
    model="qwen-turbo",
)
agent = Agent(
    model=model,
    tools=[get_weather],
)

response = agent.run("What's the weather in SF?")
print(response.content)

Configuration Options

Supported parameters for Qwen models:
from hypertic.models import Qwen
import os

model = Qwen(
    api_key=os.getenv("QWEN_API_KEY"),
    model="qwen-turbo",
    temperature=0.7,
    max_tokens=1000,
)
For the full list of available models and parameters, see the Qwen API documentation.