crewai - ✅(Solved) Fix [FEATURE] Responses API for Azure, Bedrock, Gemini, Anthropic [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
crewAIInc/crewAI#4957Fetched 2026-04-08 01:07:03
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1labeled ×1referenced ×1

Fix Action

Fixed

PR fix notes

PR #4958: feat: add Responses API support for Azure, Bedrock, Gemini, Anthropic providers

Description (problem / solution / changelog)

Summary

Implements Responses API support for Azure OpenAI using the openai SDK's AzureOpenAI client, and adds an api parameter to Bedrock, Gemini, and Anthropic providers that raises NotImplementedError with clear guidance when api="responses" is used.

Azure (full implementation):

  • New api parameter: "completions" (default, backward-compatible) or "responses"
  • Uses openai.AzureOpenAI / AsyncAzureOpenAI for the Responses API (Azure AI Inference SDK doesn't support it yet)
  • Supports: instructions, store, previous_response_id, include, builtin_tools, parse_tool_outputs, auto_chain, auto_chain_reasoning, seed, reasoning_effort, max_completion_tokens
  • System messages extracted to instructions; tools converted to internally-tagged format; structured output via text.format
  • Auto-chaining via response IDs and ZDR-compliant reasoning item tracking
  • Sync/async streaming support

Bedrock, Gemini, Anthropic (error handling only):

  • New api parameter with NotImplementedError when api="responses" is passed
  • Error messages reference each provider's native API and suggest api='completions'

Closes #4957

Review & Testing Checklist for Human

  • Verify _handle_responses / _ahandle_responses / streaming handler correctness — these ~400 lines of response handling, tool execution, and auto-chaining logic (azure/completion.py lines ~1300–1990) have zero integration test coverage. All tests mock away the actual API call. Manually test against a real Azure OpenAI endpoint with api="responses" to validate tool calling, streaming, structured output, and multi-turn chaining.
  • Validate Azure API version "2025-03-01-preview" — this is hardcoded as the default for Responses API clients (line ~268). Confirm this version is available on your Azure deployments and supports the Responses API.
  • Check openai package version compatibility — the implementation uses openai.AzureOpenAI(...).responses.create(). Verify that the openai version pinned in pyproject.toml (>=1.83.0) actually has responses.create() on the AzureOpenAI client.
  • Review _convert_tools_for_responses and _prepare_responses_params — these transform Chat Completions-style tool dicts to Responses API format. Edge cases with nested schemas, function-wrapped tools, or tools with strict mode may not be handled.
  • Test ResponsesAPIResult import from OpenAI provider — Azure imports ResponsesAPIResult from crewai.llms.providers.openai.completion. This cross-provider coupling should work but is worth verifying won't break if the OpenAI provider changes.

Notes

  • The _call_responses path is only activated when api="responses" is explicitly set, so existing api="completions" (default) behavior is completely unchanged.
  • Tests are all unit-level with mocks — no VCR cassettes or live API calls. The 37 Azure tests primarily cover _prepare_responses_params and initialization; the actual response handling code paths are untested.
  • ~888 new lines in azure/completion.py — the bulk of the PR and highest review priority.

Link to Devin session: https://app.devin.ai/sessions/f7684e6b99e24a33a5303a862cb31d4d

Changed files

  • lib/crewai/src/crewai/llms/providers/anthropic/completion.py (modified, +11/-0)
  • lib/crewai/src/crewai/llms/providers/azure/completion.py (modified, +1012/-2)
  • lib/crewai/src/crewai/llms/providers/bedrock/completion.py (modified, +12/-1)
  • lib/crewai/src/crewai/llms/providers/gemini/completion.py (modified, +11/-0)
  • lib/crewai/tests/llms/anthropic/test_anthropic.py (modified, +52/-0)
  • lib/crewai/tests/llms/azure/test_azure.py (modified, +781/-0)
  • lib/crewai/tests/llms/bedrock/test_bedrock.py (modified, +53/-0)
  • lib/crewai/tests/llms/google/test_google.py (modified, +52/-0)
RAW_BUFFERClick to expand / collapse

Feature Area

Core functionality

Is your feature request related to a an existing bug? Please link it here.

Support for the Responses API was added for OpenAI in this commit: https://github.com/crewAIInc/crewAI/commit/c4c92082297187ce01d917a9d24461f082b3109b#diff-4534b083df8dcb0882f6a62e0b98ce2520bcdde53d04a43b6488d0322485aefc in this file: https://github.com/crewAIInc/crewAI/blob/c4c92082297187ce01d917a9d24461f082b3109b/lib/crewai/src/crewai/llms/providers/openai/completion.py

If any other providers are used, the Responses API is not supported. This is a problem, as many new models don't support the Completions API any more.

Describe the solution you'd like

For consistency, the solution should be implemented similarly to how it was implemented here for OpenAI: https://github.com/crewAIInc/crewAI/blob/c4c92082297187ce01d917a9d24461f082b3109b/lib/crewai/src/crewai/llms/providers/openai/completion.py

Describe alternatives you've considered

No response

Additional context

No response

Willingness to Contribute

No, I'm just suggesting the idea

extent analysis

Fix Plan

To add support for the Responses API in other providers, follow these steps:

Example code snippet for a new provider (e.g. new_provider):

# lib/crewai/src/crewai/llms/providers/new_provider/completion.py
from crewai.llms.providers import Provider

class NewProviderCompletion(Provider):
    def __init__(self, api_key, **kwargs):
        super().__init__(api_key, **kwargs)

    def get_response(self, prompt, **kwargs):
        # Implement the Responses API call for the new provider
        response = self._make_request('post', '/v1/completions', json={'prompt': prompt, **kwargs})
        return response.json()

Verification

To verify that the fix worked, test the Responses API for each updated provider using a sample prompt and check the response for correctness.

Extra Tips

  • Make sure to handle any errors or exceptions that may occur during the API call
  • Consider adding logging or monitoring to track the usage and performance of the Responses API
  • Keep the implementation consistent with the OpenAI implementation to ensure ease of maintenance and updates.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING