Skip to content

fix: Azure Responses API URL construction with deployment paths - #61

Merged
josemaria-vilaplana merged 1 commit into
carto/mainfrom
fix/azure-responses-api-url
Dec 17, 2025
Merged

fix: Azure Responses API URL construction with deployment paths#61
josemaria-vilaplana merged 1 commit into
carto/mainfrom
fix/azure-responses-api-url

Conversation

@josemaria-vilaplana

Copy link
Copy Markdown

Summary

  • Fix Azure Responses API URL construction when api_base contains deployment paths
  • Strip deployment-specific paths (e.g., /openai/deployments/gpt-4o/chat/completions) before constructing the Responses API URL
  • Add unit tests for URL construction scenarios

Problem

When api_base is configured with deployment paths (common for Chat Completions API), the Responses API incorrectly appends /openai/responses to the full path, resulting in 404 errors:

Input:  https://...openai.azure.com/openai/deployments/gpt-4o/chat/completions
Result: https://...openai.azure.com/openai/deployments/gpt-4o/chat/completions/openai/responses ❌

Solution

Unlike Chat Completions API which uses /openai/deployments/{deployment-id}/chat/completions, the Azure Responses API uses a single endpoint /openai/responses and the model is specified in the request body.

The fix strips deployment paths from api_base before constructing the URL:

Input:  https://...openai.azure.com/openai/deployments/gpt-4o/chat/completions
Result: https://...openai.azure.com/openai/responses ✓

Test plan

  • Unit tests added for URL construction with various api_base formats
  • Docker image built successfully (litellm-azure-fix)

🤖 Generated with Claude Code

Strip deployment-specific paths from api_base when constructing Azure
Responses API URLs. Unlike Chat Completions API which uses
/openai/deployments/{deployment-id}/chat/completions, the Responses API
uses /openai/responses and the model is specified in the request body.

This fixes 404 errors when api_base is configured with deployment paths
(e.g., .../openai/deployments/gpt-4o/chat/completions).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

@mateo-di mateo-di left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@josemaria-vilaplana
josemaria-vilaplana merged commit e589816 into carto/main Dec 17, 2025
5 of 6 checks passed
@josemaria-vilaplana
josemaria-vilaplana deleted the fix/azure-responses-api-url branch December 17, 2025 08:38
josemaria-vilaplana added a commit that referenced this pull request Jan 21, 2026
…404 errors

When api_base is configured with full deployment paths like
.../openai/deployments/gpt-4o/chat/completions, the Azure SDK appends
the operation path again, resulting in duplicate paths and 404 errors.

This fix updates select_azure_base_url_or_endpoint to strip operation
suffixes (/chat/completions, /completions, /embeddings, /audio/speech,
/audio/transcriptions, /images/generations) before passing the URL
to the Azure SDK.

This is the counterpart to PR #61 which fixed the same issue for the
Responses API.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
mateo-di added a commit that referenced this pull request Jan 29, 2026
…ution

Replace simple PR listing with intelligent context building:

- Fetch ALL merged PRs to carto/main (up to 1000, no arbitrary limit)
- For each CARTO-modified conflicted file, show:
  - Which PRs modified it
  - PR title (what the change does)
  - Author and lines changed (+/-)
  - Summary from PR description (first 150 chars)
- Provide full PR reference table sorted by recency

Example context for Claude:
```
### `litellm/llms/azure/chat/gpt_transformation.py`
**2 CARTO PR(s) modified this file:**
  - PR #70: fix(azure): Strip operation suffixes from deployment URLs
    Author: @josemaria-vilaplana | +189/-1 lines
  - PR #61: fix: Azure Responses API URL construction
    Author: @josemaria-vilaplana | +77/-3 lines
```

This gives Claude full understanding of WHY each file was modified,
enabling smarter conflict resolution decisions.
mateo-di added a commit that referenced this pull request Jan 29, 2026
* feat: Implement CARTO-First resolution strategy for upstream syncs

Add CARTO-FIRST conflict resolution priority that mandates preserving
CARTO customizations made by CartoDB org members during upstream syncs.

Key changes:
- Resolver: Add pre-analysis step to identify CARTO-modified files
- Resolver: Update prompt with CARTO-FIRST priority table (6 priorities)
- Resolver: Add known CARTO customizations list (Azure, Snowflake, etc.)
- CI Fixer: Add FORBIDDEN ACTIONS (never revert CARTO code)
- CI Fixer: Add REQUIRED ACTIONS (fix tests, not CARTO code)
- Docs: Update CARTO_CLAUDE.md with new resolution priorities

The key insight is using `git log` to identify files with commits from
@carto.com or @cartodb.com authors, then prioritizing those files.

[sc-XXXXX]

* fix: Use GitHub org membership check instead of email domains

Update CARTO file detection to use GitHub API org membership check,
matching the approach in calculate_carto_version.sh (PR #72).

Changes:
- Resolver: Fetch CartoDB org members via `gh api orgs/CartoDB/members`
- Resolver: Check commit authors against org member list
- CI Fixer: Update docs to reference "CartoDB GitHub org members"
- Docs: Update CARTO_CLAUDE.md with org membership reference

This is more reliable than email domain matching because:
- GitHub usernames are authoritative
- Works for users with non-CARTO emails
- Consistent with version calculator logic

* feat: Build rich CARTO context from ALL merged PRs for conflict resolution

Replace simple PR listing with intelligent context building:

- Fetch ALL merged PRs to carto/main (up to 1000, no arbitrary limit)
- For each CARTO-modified conflicted file, show:
  - Which PRs modified it
  - PR title (what the change does)
  - Author and lines changed (+/-)
  - Summary from PR description (first 150 chars)
- Provide full PR reference table sorted by recency

Example context for Claude:
```
### `litellm/llms/azure/chat/gpt_transformation.py`
**2 CARTO PR(s) modified this file:**
  - PR #70: fix(azure): Strip operation suffixes from deployment URLs
    Author: @josemaria-vilaplana | +189/-1 lines
  - PR #61: fix: Azure Responses API URL construction
    Author: @josemaria-vilaplana | +77/-3 lines
```

This gives Claude full understanding of WHY each file was modified,
enabling smarter conflict resolution decisions.
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.

2 participants