Skip to content

Upgrade to OpenAI Responses API and remove GitHub Models support#17

Merged
pamelafox merged 3 commits intomainfrom
upgrade-responses
Apr 6, 2026
Merged

Upgrade to OpenAI Responses API and remove GitHub Models support#17
pamelafox merged 3 commits intomainfrom
upgrade-responses

Conversation

@pamelafox
Copy link
Copy Markdown
Contributor

@pamelafox pamelafox commented Apr 5, 2026

Summary

Migrates all scripts from the Chat Completions API to the OpenAI Responses API, and removes GitHub Models as an LLM provider (it doesn't support the Responses API).

66 files changed, 884 insertions, 1244 deletions.

Responses API migration

All 55+ Python scripts (English + Spanish) updated:

Change Before After
Client (Azure) AzureOpenAI() OpenAI(base_url=f"{endpoint}/openai/v1/")
API calls client.chat.completions.create(messages=...) client.responses.create(input=..., store=False)
Response access response.choices[0].message.content response.output_text
Streaming event.choices[0].delta.content event.type == "response.output_text.delta" / event.delta
Tool definitions {"type": "function", "function": {"name": ...}} {"type": "function", "name": ...} (flat format)
Tool results {"role": "tool", "tool_call_id": ...} {"type": "function_call_output", "call_id": ...}
Structured outputs client.beta.chat.completions.parse(response_format=...) client.responses.parse(text_format=...)
Reasoning reasoning_effort="low" reasoning={"effort": "low"}

Function calling specifics

  • Tool definitions flattened to Responses API format (name/parameters at top level)
  • Multi-turn tool results use response.output items + function_call_output
  • Few-shot tool examples use function_call/function_call_output items with fc_ ID prefix
  • strict: true schemas include required and additionalProperties: false

GitHub Models removal

  • Removed elif API_HOST == "github" block from all 58 Python scripts
  • Changed default API_HOST from "github" to "azure"
  • Deleted .env.sample.github and .devcontainer/github/
  • Removed GitHub Models sections from README.md, spanish/README.md, and AGENTS.md

Infrastructure

  • Updated infra/main.bicep model defaults to gpt-5.4 (version 2026-03-05)
  • Removed AZURE_OPENAI_VERSION from .env, write_dot_env.sh, write_dot_env.ps1
  • Fixed provisioning scripts that were baking /openai/v1 into the endpoint (scripts already append it)

Verification

  • ruff check . — all passed
  • black . --check — all passed
  • Copilot ran the 24 non-interactive English scripts
  • I manually ran the interactive English scripts

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the repository’s Python demos from the Chat Completions API to the OpenAI Responses API, and removes GitHub Models as an LLM provider (since it doesn’t support the Responses API).

Changes:

  • Switched all example scripts to client.responses.create(...) / client.responses.parse(...), updating streaming, tool-calling, and structured outputs usage.
  • Removed GitHub Models provider selection and related docs/devcontainer assets; default host is now Azure.
  • Updated infra/env tooling so AZURE_OPENAI_ENDPOINT is no longer expected to include /openai/v1.
Show a summary per file
File Description
structured_outputs_nested.py Migrate structured output parsing + Azure base_url normalization
structured_outputs_function_calling.py Migrate tool calling example to Responses API
structured_outputs_enum.py Migrate structured output parsing to Responses API
structured_outputs_description.py Migrate structured output parsing to Responses API
structured_outputs_basic.py Migrate structured output parsing to Responses API
spanish/structured_outputs_nested.py Spanish structured output parsing migration
spanish/structured_outputs_function_calling.py Spanish tool calling + Responses API migration
spanish/structured_outputs_enum.py Spanish structured output parsing migration
spanish/structured_outputs_description.py Spanish structured output parsing migration
spanish/structured_outputs_basic.py Spanish structured output parsing migration
retrieval_augmented_generation.py RAG script migrated to Responses API
spanish/retrieval_augmented_generation.py Spanish RAG script migrated to Responses API
rag_queryrewrite.py Query rewrite flow migrated to Responses API
spanish/rag_queryrewrite.py Spanish query rewrite flow migrated to Responses API
rag_multiturn.py Multi-turn RAG migrated to Responses API
spanish/rag_multiturn.py Spanish multi-turn RAG migrated to Responses API
rag_documents_ingestion.py Removed GitHub provider option from ingestion script
spanish/rag_documents_ingestion.py Removed GitHub provider option from ingestion script
rag_documents_hybrid.py Hybrid RAG generation migrated to Responses API
spanish/rag_documents_hybrid.py Spanish hybrid RAG generation migrated to Responses API
rag_documents_flow.py RAG flow generation migrated to Responses API
spanish/rag_documents_flow.py Spanish RAG flow generation migrated to Responses API
rag_csv.py CSV RAG generation migrated to Responses API
spanish/rag_csv.py Spanish CSV RAG generation migrated to Responses API
prompt_engineering.py Prompting demo migrated to Responses API
spanish/prompt_engineering.py Spanish prompting demo migrated to Responses API
function_calling_basic.py Basic tool-calling demo migrated to Responses API
spanish/function_calling_basic.py Spanish basic tool-calling demo migrated to Responses API
function_calling_call.py Tool execution demo migrated to Responses API
spanish/function_calling_call.py Spanish tool execution demo migrated to Responses API
function_calling_extended.py Full tool round-trip migrated to Responses API
spanish/function_calling_extended.py Spanish full tool round-trip migrated to Responses API
function_calling_errors.py Tool error-handling demo migrated to Responses API
spanish/function_calling_errors.py Spanish tool error-handling demo migrated to Responses API
function_calling_fewshots.py Few-shot tool-calling format updated for Responses API
spanish/function_calling_fewshots.py Spanish few-shot tool-calling format updated for Responses API
function_calling_parallel.py Parallel tool calls demo migrated to Responses API
spanish/function_calling_parallel.py Spanish parallel tool calls demo migrated to Responses API
function_calling_while_loop.py Looping tool-calling demo migrated to Responses API
spanish/function_calling_while_loop.py Spanish looping tool-calling demo migrated to Responses API
few_shot_examples.py Few-shot chat demo migrated to Responses API
spanish/few_shot_examples.py Spanish few-shot chat demo migrated to Responses API
chat.py Basic chat demo migrated to Responses API
spanish/chat.py Spanish basic chat demo migrated to Responses API
chat_stream.py Streaming demo migrated to Responses API streaming events
spanish/chat_stream.py Spanish streaming demo migrated to Responses API streaming events
chat_safety.py Safety demo migrated to Responses API output access
spanish/chat_safety.py Spanish safety demo migrated to Responses API output access
chat_history.py History demo migrated to Responses API output access
spanish/chat_history.py Spanish history demo migrated to Responses API output access
chat_history_stream.py History streaming demo migrated to Responses API streaming events
spanish/chat_history_stream.py Spanish history streaming demo migrated to Responses API streaming events
chat_async.py Async demo migrated to Responses API
spanish/chat_async.py Spanish async demo migrated to Responses API
chained_calls.py Multi-call chaining migrated to Responses API
spanish/chained_calls.py Spanish multi-call chaining migrated to Responses API
reasoning.py Reasoning example migrated to Responses API + reasoning config update
README.md Removed GitHub Models documentation; updated provider framing
spanish/README.md Removed GitHub Models documentation; updated Azure endpoint guidance
AGENTS.md Updated agent guidance for provider removal/defaults
infra/main.bicep Updated model defaults (name/version/deployment)
infra/write_dot_env.sh Stop appending /openai/v1 / removing version var from .env generation
infra/write_dot_env.ps1 Stop appending /openai/v1 / removing version var from .env generation
.env.sample Updated supported hosts + Azure endpoint format; removed GitHub vars
.env.sample.github Removed GitHub-only sample env file
.devcontainer/github/devcontainer.json Removed GitHub Models devcontainer variant

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (2)

AGENTS.md:11

  • Documentation is now out of sync with the codebase: this section still describes the repo as demonstrating “chat completions” and lists “Chat Completion Scripts”, but the scripts were migrated to the Responses API. Update the terminology/examples so new contributors aren’t guided toward deprecated APIs.
This repository contains a collection of Python scripts that demonstrate how to use the OpenAI API (and compatible APIs like Azure OpenAI and Ollama) to generate chat completions. The repository includes examples of:

- Basic chat completions (streaming, async, history)
- Function calling (basic to advanced multi-function scenarios)
- Structured outputs using Pydantic models

AGENTS.md:176

  • This section instructs users to set/check OPENAI_API_KEY, but the scripts and .env.sample use OPENAI_KEY for OpenAI.com. Align the documentation with the actual env var name (or update the scripts to read OPENAI_API_KEY) to avoid misconfiguration.
#### Option 2: OpenAI.com (requires API key and costs)

**For agents:** Check if OpenAI.com API key is available:
```bash
if [ -n "$OPENAI_API_KEY" ]; then
  • Files reviewed: 66/66 changed files
  • Comments generated: 10

@pamelafox pamelafox merged commit cd06b0d into main Apr 6, 2026
2 checks passed
@pamelafox pamelafox deleted the upgrade-responses branch April 6, 2026 20:45
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.

3 participants