Skip to content

ccproxy.llms.formatters.anthropic_to_openai.streams

ccproxy.llms.formatters.anthropic_to_openai.streams

Anthropic→OpenAI streaming conversion entry points.

AnthropicToOpenAIResponsesStreamAdapter

Stateful adapter for Anthropic → OpenAI Responses streaming.

AnthropicToOpenAIChatStreamAdapter

Stateful adapter for Anthropic → OpenAI Chat streaming.

convert__anthropic_message_to_openai_responses__stream async

convert__anthropic_message_to_openai_responses__stream(
    stream,
)

Convert Anthropic MessageStreamEvents into OpenAI Responses stream events.

Source code in ccproxy/llms/formatters/anthropic_to_openai/streams.py
async def convert__anthropic_message_to_openai_responses__stream(
    stream: AsyncIterator[anthropic_models.MessageStreamEvent],
) -> AsyncGenerator[openai_models.StreamEventType, None]:
    """Convert Anthropic MessageStreamEvents into OpenAI Responses stream events."""

    adapter = AnthropicToOpenAIResponsesStreamAdapter()
    async for event in adapter.run(stream):
        yield event

convert__anthropic_message_to_openai_chat__stream async

convert__anthropic_message_to_openai_chat__stream(stream)

Convert Anthropic stream to OpenAI stream using ClaudeAccumulator.

Source code in ccproxy/llms/formatters/anthropic_to_openai/streams.py
async def convert__anthropic_message_to_openai_chat__stream(
    stream: AsyncIterator[anthropic_models.MessageStreamEvent],
) -> AsyncGenerator[openai_models.ChatCompletionChunk, None]:
    """Convert Anthropic stream to OpenAI stream using ClaudeAccumulator."""

    adapter = AnthropicToOpenAIChatStreamAdapter()
    async for chunk in adapter.run(stream):
        yield chunk