Next-generation AI agent API - combining Chat Completions simplicity with powerful tool calling capabilities
APIYI fully supports OpenAI’s latest Responses API, the next-generation AI agent building interface launched in March 2025. The Responses API combines the simplicity of Chat Completions with the tool usage and state management capabilities of the Assistants API, providing developers with a more flexible and powerful AI application building experience.
Next-Generation API: Responses API is a superset of Chat Completions, providing Chat Completions functionality while also supporting advanced features like built-in tools and state management. — However, it only supports a few newer OpenAI models. See below for details.
curl https://api.apiyi.com/v1/responses \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "model": "gpt-4.1", "input": "Hello! How can you help me today?", "instructions": "You are a helpful assistant." }'
response = client.responses.create( model="gpt-4.1", input="Create a chart showing sales data: Jan:100, Feb:150, Mar:120", instructions="You are a data analyst. Use code interpreter to create visualizations.", tools=[{"type": "code_interpreter"}])
response = client.responses.create( model="gpt-4.1", input="Search for information about quarterly reports", instructions="You are a document analyst.", tools=[{"type": "file_search"}])
# First conversation turnresponse1 = client.responses.create( model="gpt-4.1", input="My name is Alice. Please remember this.", instructions="You are a helpful assistant with good memory.")# Second conversation turn - use previous_response_id to maintain contextresponse2 = client.responses.create( model="gpt-4.1", input="What's my name?", instructions="You are a helpful assistant with good memory.", previous_response_id=response1.id)print(response2.output[0].content[0].text) # Should answer "Alice"
def multi_turn_conversation(): response_id = None for user_input in ["What's 2+2?", "Now multiply that by 3", "And divide by 2"]: response = client.responses.create( model="o3", input=user_input, instructions="You are a math tutor. Show your reasoning.", previous_response_id=response_id, tools=[{"type": "code_interpreter"}] ) print(f"User: {user_input}") print(f"Assistant: {response.output[0].content[0].text}") response_id = response.id # Maintain context
Reasoning models have special advantages in Responses API:
Copy
# Use O3 for complex reasoningresponse = client.responses.create( model="o3", input="Solve this step by step: If a train travels 120km in 2 hours, then speeds up 20% for the next hour, how far did it travel in total?", instructions="Think through this problem step by step, showing all reasoning.")# View reasoning processreasoning_tokens = response.usage.output_tokens_details.reasoning_tokensprint(f"Reasoning tokens used: {reasoning_tokens}")# Continue conversation, reasoning context will persistfollow_up = client.responses.create( model="o3", input="Now what if the train slowed down 10% in the fourth hour?", previous_response_id=response.id)
{ "error": { "type": "invalid_request_error", "code": "model_not_supported", "message": "The model 'gpt-3.5-turbo' is not supported for the responses endpoint.", "param": "model" }}
def smart_tool_calling(user_input): # Intelligently select tools based on input available_tools = [] if "weather" in user_input.lower(): available_tools.append(weather_tool) if "calculate" in user_input.lower(): available_tools.append(calculator_tool) if "search" in user_input.lower(): available_tools.append(search_tool) response = client.responses.create( model="gpt-4.1", input=user_input, instructions="Use the appropriate tools to help the user.", tools=available_tools, tool_choice="auto" ) return response
Development Recommendation: New projects recommended to use Responses API directly, existing projects can migrate gradually. APIYI will continue to follow OpenAI updates to ensure feature completeness.