Skip to content

OpenAI Responses API

Choose a tag to compare

@ilvalerione ilvalerione released this 12 Sep 10:52
· 484 commits to 2.x since this release

OpenAI Responses API Provider

OpenAI marked completions API as deprecated and now it's promoting the transition to responses API in order to take advantage of the latest features: https://platform.openai.com/docs/guides/migrate-to-responses

To keep the compatibility with all other provders that use the OpenAI completion API format, we implemented the Responses API a seprarate provider OpenAIResponses.

You can attach this provider to your agent as usual:

class MyAgent extends Agent
{
    public function provider(): AIProviderInterface
    {
        return new OpenAIResponses(
            key: 'OPENAI_API_KEY',
            model: 'OPENAI_MODEL',
        );
    }
}

Provider Tools

With the OpenAI responses API compatibility we decided to bring into the framework also the possibility to use provider specific tools like web_search, file_search, etc offered by many providers, like: OpenAI, Gemini, Anthropic.

To instruct your agent to use a specific provider tool you can add a ProviderTool class instance in the tools lists:

use NeuronAI\Tools\ProviderTool;

class MyAgent extends Agent
{
    public function provider(): AIProviderInterface
    {
        return new OpenAIResponses(
            key: 'OPENAI_API_KEY',
            model: 'OPENAI_MODEL',
        );
    }

    public function tools(): array
    {
        return [
            ProviderTool:make(
                type: 'web_search'
            )->setOptions([...]),

            // Add other tools and toolkits as usual...
        ];
    }
}

Consider that providers has a lot of limitations in using their internal tools. The most flexible way to add capabilities to your agent remains the use of Tools & Toolkits.