Skip to content

feat(py/openai): route pro, codex and hosted-tool calls through the Responses API - #276

Open
hilariie wants to merge 2 commits into
mainfrom
feat/openai-responses-api
Open

hilariie wants to merge 2 commits into
mainfrom
feat/openai-responses-api

Conversation

@hilariie

@hilariie hilariie commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #274

genkit-openai can now call models that only exist on OpenAI's Responses API, and use OpenAI's server-run tools such as web search and image generation. Chat models keep using Chat Completions with the same request bodies as before.

# before: not listed, and a direct call 404s on Chat Completions
await ai.generate(model='openai/gpt-5.5-pro', prompt='...')

# after: listed, and the call goes to /v1/responses
await ai.generate(model='openai/gpt-5.5-pro', prompt='...')

# server-run tools on any OpenAI model
await ai.generate(
    model='openai/gpt-5.4-mini',
    prompt='What is the latest stable Python release?',
    config={'tools': [{'type': 'web_search'}]},
)

Changes

  • Pro and codex models are listed again and go to the Responses API on OpenAI's host. The catalog adds gpt-5.2-pro, gpt-5.4-pro, gpt-5.5-pro and gpt-5.3-codex.
  • gpt-6-astra and gpt-6.1-sol now report tool support. These models take function tools only on Responses, so a call to them with tools goes there instead of failing with a 400.
  • New OpenAIConfig fields:
    • transport ('auto', 'chat_completions', 'responses') picks the API for one call.
    • tools takes server-run tool entries such as web_search, image_generation or file_search.
    • previous_response_id continues from a stored response.
    • reasoning_summary asks for a summary of the model's reasoning.
  • Responses calls default to store=False. Encrypted reasoning is requested and kept on part metadata, so multi-turn conversations work without OpenAI storing anything. Generated images go back to the model only with store=True, because the API refuses them otherwise.
  • Server-run tool calls and other output items with no Genkit part kind come back in Part.custom['responsesItem'] and are sent back unchanged on the next turn.
  • Calls that can't work fail with INVALID_ARGUMENT before the request goes out:
    • transport='chat_completions' on a pro or codex model, or with config tools, on OpenAI's host.
    • transport='responses', previous_response_id or reasoning_summary on a model served only through Chat Completions.
    • Config tools entries that run in your own code, such as function or a shell.
  • With base_url= (a gateway), every model stays on Chat Completions unless the call passes transport='responses'. The Mistral, OpenAI-compatible and Google Cloud plugins reject transport='responses'.

Breaking changes

None.

Cross-SDK

The Dev UI config form for OpenAI models gains transport, tools, previous_response_id and reasoning_summary. Model responses from the Responses API carry new metadata in traces:

{"text": "Mango", "metadata": {"itemId": "msg_..."}}
{"reasoning": "...", "metadata": {"itemId": "rs_...", "encryptedContent": "..."}}
{"custom": {"responsesItem": {"type": "web_search_call", "id": "ws_...", "status": "completed"}}}

The message itself carries metadata.responseId. The Chat Completions path writes nothing new.

@genkit-bot genkit-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments

Details

Run 16046d13-2a96-4fe5-9ad5-e656df4ab391 · Cloud Run logs · Dashboard

Comment thread packages/genkit-openai/README.md Resolved
@hilariie
hilariie requested a review from genkit-bot December 3, 2026 13:37
@hilariie

hilariie commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

@genkit-bot re-review

This branch has not been deployed

No deployments
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.

[py/openai] OpenAI Responses API support

2 participants