Skip to content

Migrate from Chat Completions to Responses API#358

Open
pamelafox wants to merge 1 commit intomainfrom
responses-port
Open

Migrate from Chat Completions to Responses API#358
pamelafox wants to merge 1 commit intomainfrom
responses-port

Conversation

@pamelafox
Copy link
Copy Markdown
Collaborator

Summary

This PR migrates the OpenAI API usage from the legacy Chat Completions API to the unified Responses API.

Changes

Client Migration

  • Import: AsyncAzureOpenAIAsyncOpenAI
  • Endpoint: Uses base_url with /openai/v1 path instead of deprecated azure_endpoint
  • Auth: azure_ad_token_providerapi_key (token provider still works)
  • Removed: api_version parameter (no longer needed for Responses API)

API Call Migration

  • Method: chat.completions.create()responses.create()
  • Input format: messagesinput with structured content items
    • User/system messages use type: "input_text"
    • Assistant messages use type: "output_text"
  • Added: store=False to avoid server-side state retention

Streaming Events

  • Before: ChatCompletionChunk with choices[0].delta.content
  • After: response.output_text.delta and response.completed events

Infrastructure Cleanup

Removed AZURE_OPENAI_API_VERSION from:

  • infra/aca.bicep
  • infra/main.bicep
  • infra/main.parameters.json
  • .github/workflows/azure-dev.yaml

Dependencies

  • Updated openai>=1.108.1 in pyproject.toml
  • Regenerated requirements.txt (now uses openai 2.16.0)

Tests

  • Simplified test mocks for Responses API streaming format
  • Updated snapshot files to match new response structure
  • All 4 tests passing ✅

Files Changed (11)

File Description
src/quartapp/chat.py Main migration - client init and API call
src/pyproject.toml Updated openai version constraint
src/requirements.txt Regenerated dependencies
tests/conftest.py Simplified mock fixtures
tests/test_app.py Updated managed identity test
tests/snapshots/* Updated 2 snapshot files
infra/aca.bicep Removed API version env var
infra/main.bicep Removed API version param/output
infra/main.parameters.json Removed API version parameter
.github/workflows/azure-dev.yaml Removed API version env var

Testing

  • All unit tests pass
  • Ruff linting passes
  • Manual testing with Azure OpenAI deployment (recommended before merge)

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