Feat/OpenAI responses api 3209#6188
Open
FrigaZzz wants to merge 2 commits into
Open
Conversation
Add OpenAI and Azure OpenAI Responses API labs LLM implementations with request conversion, response parsing, streaming support, reasoning metadata, function calls, usage metadata. Fixes: google#3209
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR: Adds first-class ADK support for the OpenAI Responses API (including Azure OpenAI) via a new
labs.openai_responsesmodule. Fully additive, zero changes to existing core model APIs, 33/33 unit tests passing, plus a working Azure E2E sample.Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem
ADK has no built-in LLM implementation for the OpenAI Responses API. Anyone who wants to use OpenAI or Azure OpenAI Responses API models today has to hand-roll their own request conversion, response parsing, streaming handling, tool-call mapping, and usage-metadata handling.
Solution
This PR adds
OpenAIResponsesLlmandAzureOpenAIResponsesLlm, giving ADK native, drop-in support for Responses API models:LlmRequest→ Responses APIresponses.createparameters, covering contents, system instructions, tools, tool responses, and generation config.LlmResponse, including text, function calls, reasoning parts, finish reasons, interaction IDs, model versions, and usage metadata./openai/v1/base URL.LlmResponse.custom_metadataviainclude_response_metadata.contributing/samples/models/hello_world_azure_openai_responses, a runnable Azure OpenAI Responses reference for manual E2E validation.This lands under
google.adk.labs.openai_responses— it's additive and opt-in, with no changes to any existing core model API.Testing Plan
Unit Tests ✅
33/33 passing locally, covering 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 the
custom_metadataopt-out.uv run pytest tests/unittests/labs/openai_responses/test_openai_responses_llm.py # 33 passed, 4 warnings in 1.14sFormatted with
pyink:Manual End-to-End (E2E) Tests ✅
Verified live against Azure OpenAI Responses using the included sample:
Covers: basic text generation, function calling + function-response handling, multi-turn context preservation through the runner, and direct
previous_response_idchaining.Checklist
Additional Context
This lives under
google.adk.labs.openai_responses— a labs integration rather than a stable core model API — so it can land and iterate quickly without being bound to core API-stability guarantees, while still being fully usable today.The unit test suite targets the conversion and parsing logic directly (request shape, typed vs. mapping-based responses, function calls, reasoning metadata, usage metadata, streaming aggregation, failure paths, Azure URL construction, and metadata opt-out), so regressions in any of these areas should surface immediately.
The
hello_world_azure_openai_responsessample doubles as living documentation: it shows the exact setup and commands needed to validate the integration against a real Azure OpenAI Responses deployment.