thanks for your replies.
it did work using your code…
it still doest not work in my code… I first change you OpenAIChat to OpenAILike
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.run.response import RunResponse
task = "Give me steps to write a python script for fibonacci series"
reasoning_agent = Agent(
model=OpenAILike(
id="deepseek-v3",
api_key=getenv("ALIYUN_API_KEY"),
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
),
markdown=True,
structured_outputs=True,
reasoning=True
)
response_stream: RunResponse = reasoning_agent.run(task)
print(response_stream.extra_data)
it rase the error, it seem it will use openai model for reasoning
ERROR Error from OpenAI API: Error code: 401 - {'error': {'message': 'Incorrect API key provided: not-provided.
You can find your API key at https://platform.openai.com/account/api-keys.', 'type':
'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}
ERROR Reasoning error: You tried to pass a `BaseModel` class to `chat.completions.create()`; You must use
`beta.chat.completions.parse()` instead
So I set reasoning_model, then
task = "Give me steps to write a python script for fibonacci series"
reasoning_agent = Agent(
model=OpenAILike(
id="deepseek-v3",
api_key=getenv("ALIYUN_API_KEY"),
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
),
markdown=True,
structured_outputs=True,
reasoning=True,
reasoning_model=OpenAILike(
id="deepseek-r1",
api_key=getenv("ALIYUN_API_KEY"),
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)
)
response_stream: RunResponse = reasoning_agent.run(task)
print(response_stream.extra_data)
it rase the error
ERROR Error from OpenAI API: Error code: 400 - {'error': {'code': 'invalid_parameter_error', 'param': None,
'message': "<400> InternalError.Algo.InvalidParameter: 'messages' must contain the word 'json' in some
form, to use 'response_format' of type 'json_object'.", 'type': 'invalid_request_error'}, 'id':
'chatcmpl-423716b8-a92d-9054-ac3d-43712fb2e18c', 'request_id': '423716b8-a92d-9054-ac3d-43712fb2e18c'}
ERROR Reasoning error: You tried to pass a `BaseModel` class to `chat.completions.create()`; You must use
`beta.chat.completions.parse()` instead
But if I use openai
, I can geti it using following code:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("ALIYUN_API_KEY"),
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
model="deepseek-r1",
messages=[
{'role': 'user', 'content': "how many 'r' in word 'Strawberry'"}
]
)
print(completion.choices[0].message.reasoning_content)