Skip to content

feat: add openai compatible response support for anthropic on azure#1465

Merged
VisargD merged 5 commits into
Portkey-AI:mainfrom
arturfromtabnine:ar/fix-azure-ai-anthropic-stream-response
Dec 17, 2025
Merged

feat: add openai compatible response support for anthropic on azure#1465
VisargD merged 5 commits into
Portkey-AI:mainfrom
arturfromtabnine:ar/fix-azure-ai-anthropic-stream-response

Conversation

@arturfromtabnine

Copy link
Copy Markdown
Contributor

Description: (required)
Without steam-chatComplete response transformer specified , stream response from anthropic model hosted on azure is native anthropic sse and not open ai compatible

curl --location 'http://localhost:8787/v1/chat/completions' \
--header 'x-portkey-provider: azure-ai' \
--header 'Authorization: $AZURE_API_KEY' \
--header 'x-portkey-azure-foundry-url: https://resource-name.services.ai.azure.com/anthropic' \
--header 'Content-Type: application/json' \
--data '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 10000,
    "messages": [
        {
            "role": "system",
            "content": "You are a helpful assistant."
        },
        {
            "role": "user",
            "content": "why sky is blue?"
        }
    ],
    "stream": true,
    "stream_options": {
        "include_usage": true
    },
    "anthropicBeta": "fine-grained-tool-streaming-2025-05-14"
}'

example of stream chunk before change

{
    "type": "content_block_delta",
    "index": 0,
    "delta": {
        "type": "text_delta",
        "text": " re"
    }
}

after the change

{
    "id": "azure-ai-1765363108622",
    "object": "chat.completion.chunk",
    "created": 1765363114,
    "model": "claude-sonnet-4-5-20250929",
    "provider": "anthropic",
    "choices": [
        {
            "delta": {
                "content": " re"
            },
            "index": 0,
            "logprobs": null,
            "finish_reason": null
        }
    ]
}

Tests Run/Test cases added: (required)

  • Description of test case

Type of Change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

@narengogi

Copy link
Copy Markdown
Member

valid

@narengogi

narengogi commented Dec 11, 2025

Copy link
Copy Markdown
Member

I've updated the PR to make this fully feature complete

@narengogi narengogi requested review from VisargD and b4s36t4 December 15, 2025 08:03
@VisargD VisargD merged commit 1e4891d into Portkey-AI:main Dec 17, 2025
1 check passed
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