Skip to content

Issue 1 feat plugin add native anthropic streaming and prompt caching support - #2

Open
An-Dongsun wants to merge 5 commits into
masterfrom
issue-1-feat-plugin-add-native-anthropic-streaming-and-prompt-caching-support
Open

Issue 1 feat plugin add native anthropic streaming and prompt caching support#2
An-Dongsun wants to merge 5 commits into
masterfrom
issue-1-feat-plugin-add-native-anthropic-streaming-and-prompt-caching-support

Conversation

@An-Dongsun

Copy link
Copy Markdown
Collaborator

Closes #1

Summary

Kong ai-proxy를 Full Fork하여 Native Anthropic Streaming과 Prompt Caching을 지원하는 ai-anthropic-native 플러그인 추가

  • Native Anthropic SSE 스트리밍 지원 (OpenAI 변환 스킵)
  • Prompt Caching 지원 (cache_control 자동 주입)
  • 캐시 메트릭 응답 헤더 노출 (X-Cache-Creation-Input-Tokens, X-Cache-Read-Input-Tokens)
  • Anthropic 직접 호출 및 AWS Bedrock 지원

Changes

영역 설명
kong/llm/ LLM 프레임워크 (드라이버, 어댑터, 필터)
kong/plugins/ai-anthropic-native/ 새 플러그인 (handler, schema)
kong/llm/plugin/shared-filters/inject-cache-control.lua Prompt caching cache_control 주입
kong/llm/plugin/shared-filters/expose-cache-metrics.lua 캐시 메트릭 헤더 노출

Configuration Example

plugin: ai-anthropic-native
config:
  model:
    provider: "bedrock"
    name: "anthropic.claude-3-5-sonnet-20241022-v2:0"
  native_streaming: true
  prompt_caching:
    enabled: true
    cache_system_prompt: true
    cache_tools: true
    ttl: "5m"
  expose_cache_metrics: true

@An-Dongsun An-Dongsun self-assigned this Feb 3, 2026
@An-Dongsun An-Dongsun added the enhancement New feature or request label Feb 3, 2026
@An-Dongsun An-Dongsun linked an issue Feb 3, 2026 that may be closed by this pull request
11 tasks

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a custom Kong plugin ai-anthropic-native that enables native Anthropic SDK compatibility for AWS Bedrock Claude models. It implements native streaming in Anthropic SSE format (bypassing OpenAI conversion), prompt caching with automatic cache_control injection, and cache metrics exposure via response headers.

Changes:

  • New plugin with native Anthropic streaming support (preserves Anthropic SSE format instead of converting to OpenAI)
  • Prompt caching support with automatic cache_control injection into system prompts and tools
  • Cache metrics exposure through custom response headers
  • Extended Thinking (Claude 4) support via thinking parameter conversion
  • Full LLM framework fork from Kong AI Proxy including drivers, adapters, and shared filters

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated no comments.

Show a summary per file
File Description
kong/plugins/ai-anthropic-native/handler.lua Plugin handler registering custom filters including inject-cache-control and expose-cache-metrics
kong/plugins/ai-anthropic-native/schema.lua Plugin schema with native_streaming, prompt_caching, and expose_cache_metrics configuration
kong/llm/plugin/shared-filters/inject-cache-control.lua Filter to inject cache_control into system prompts and tools for Anthropic prompt caching
kong/llm/plugin/shared-filters/expose-cache-metrics.lua Filter to expose cache metrics as response headers
kong/llm/drivers/anthropic.lua Anthropic driver with native streaming preserve mode support
kong/llm/drivers/bedrock.lua Bedrock driver with Bedrock EventStream to Anthropic SSE conversion and Extended Thinking support
kong/llm/adapters/anthropic.lua Anthropic format adapter for native format passthrough
kong/llm/adapters/bedrock.lua Bedrock format adapter
kong/llm/adapters/gemini.lua Gemini format adapter
spec/ai-anthropic-native/*.lua Schema and unit tests for the plugin
kong.yml.template Configuration template with examples
kong-plugin-ai-anthropic-native-0.1.0-1.rockspec LuaRocks package specification

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(plugin): add native Anthropic streaming and prompt caching support

3 participants