Skip to content

feat(models): add Azure OpenAI Responses API support#149

Open
FrigaZzz wants to merge 2 commits into
google:mainfrom
FrigaZzz:feat/azure-openai-responses-api
Open

feat(models): add Azure OpenAI Responses API support#149
FrigaZzz wants to merge 2 commits into
google:mainfrom
FrigaZzz:feat/azure-openai-responses-api

Conversation

@FrigaZzz
Copy link
Copy Markdown

@FrigaZzz FrigaZzz commented May 29, 2026

Link to Issue

Problem:
google-adk-community does not currently provide a model adapter for the OpenAI Responses API. Users who want to use OpenAI or Azure OpenAI Responses API models with ADK need to build their own request conversion, response parsing, streaming handling, tool-call mapping, and usage metadata handling.

Solution:
Add support for OpenAI Responses API models through OpenAIResponsesLlm and AzureOpenAIResponsesLlm under google.adk_community.models.openai_responses.

This change adds:

  • Request conversion from ADK LlmRequest into OpenAI Responses API responses.create parameters.
  • Conversion of ADK contents, system instructions, tools, tool responses, and generation config into Responses API-compatible shapes.
  • Response parsing into ADK LlmResponse, including text, function calls, reasoning parts, finish reasons, interaction IDs, model versions, and usage metadata.
  • Streaming support for Responses API events, including partial text and reasoning deltas plus final response aggregation.
  • Azure OpenAI-compatible client support using the /openai/v1/ base URL.
  • Optional OpenAI response metadata on LlmResponse.custom_metadata via include_response_metadata.
  • An openai optional dependency extra for installing the OpenAI SDK with the community package.
  • Package documentation for OpenAI and Azure OpenAI Responses usage.
  • A contribution sample under contributing/samples/models/hello_world_azure_openai_responses for manual Azure OpenAI Responses E2E validation.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • Targeted unit tests pass locally.
  • Existing unit tests pass locally.

Targeted model tests:

uv run --native-tls --extra test --extra openai pytest tests/unittests/models/openai_responses -q

Result:

33 passed in 1.07s

CI-style unit test run using the test extra:

uv sync --native-tls --extra test
uv run --native-tls --extra test pytest tests/unittests -q

Result:

76 passed, 13 skipped in 1.17s

Full unit test run with all extras:

uv run --native-tls --all-extras pytest tests/unittests -q

Result:

101 passed in 3.17s

Build validation:

uv build --native-tls

Result:

Successfully built dist/google_adk_community-0.5.0.tar.gz
Successfully built dist/google_adk_community-0.5.0-py3-none-any.whl

Formatting:

uvx --native-tls isort src/google/adk_community/models/openai_responses/_openai_responses_llm.py src/google/adk_community/models/openai_responses/__init__.py tests/unittests/models/openai_responses/test_openai_responses_llm.py
uvx --native-tls pyink --config pyproject.toml src/google/adk_community/models/openai_responses/_openai_responses_llm.py src/google/adk_community/models/openai_responses/__init__.py tests/unittests/models/openai_responses/test_openai_responses_llm.py

Sample import validation:

uv run --native-tls --extra test --extra openai python -c "import sys; sys.path.insert(0, 'contributing/samples/models'); import hello_world_azure_openai_responses.agent as agent; print(agent.root_agent.name)"

Result:

azure_openai_responses_agent

Manual End-to-End (E2E) Tests:

Manual live Azure OpenAI E2E testing can be run with the included sample:

cd contributing/samples/models/hello_world_azure_openai_responses
python main.py

The sample validates:

  • Runner basic text generation using AzureOpenAIResponsesLlm.
  • Runner function calling and function response handling.
  • Multi-turn context preservation through the runner.
  • Direct Responses API previous_response_id chaining.

Manual live Azure OpenAI E2E output is not included here because it requires a live Azure OpenAI deployment. The Azure-specific client behavior is covered by isolated unit tests for client construction, including the /openai/v1/ base URL used by Azure OpenAI Responses API deployments.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code where helpful for hard-to-understand areas.
  • I have added tests that prove my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have validated the package builds locally.
  • I have added a manual E2E sample for live Azure OpenAI validation.
  • I have manually tested against a live Azure OpenAI Responses deployment.

Additional context

This contribution targets google-adk-community, so the integration is added under google.adk_community.models.openai_responses instead of the core ADK package.

The targeted unit test suite covers request shape conversion, typed and mapping-based response parsing, function calls, reasoning metadata, usage metadata, streaming aggregation, failed stream handling, Azure base URL construction, and disabling response metadata in custom_metadata.

The openai optional extra allows users to install the OpenAI SDK dependency only when they need this model integration:

pip install "google-adk-community[openai]"

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 29, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

FrigaZzz added 2 commits May 29, 2026 11:40
Add OpenAI Responses API model adapters for the community package, including Azure OpenAI support through the OpenAI-compatible /openai/v1/responses endpoint.
Also add the OpenAI optional dependency extra, model documentation, and unit coverage for request mapping, streaming, tool calls, metadata, and Azure client configuration.
Add community model adapters for the OpenAI Responses API, including Azure OpenAI support through the OpenAI-compatible /openai/v1/responses endpoint.
The adapters convert ADK requests, content, tools, tool responses, generation config, streaming events, and response metadata to and from Responses API shapes.
Also add the OpenAI optional dependency extra, unit coverage, package documentation, and an Azure OpenAI manual E2E sample under contributing/samples/models.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant