Skip to content

feat(ai-proxy): support qiniu ai provider#3561

Open
jiahuipaung wants to merge 1 commit intoalibaba:mainfrom
qiniu:feat/add-qiniu-provider
Open

feat(ai-proxy): support qiniu ai provider#3561
jiahuipaung wants to merge 1 commit intoalibaba:mainfrom
qiniu:feat/add-qiniu-provider

Conversation

@jiahuipaung
Copy link

Ⅰ. Describe what this PR did

Add Qiniu (七牛云) AI provider support to the ai-proxy plugin.

The Qiniu provider is OpenAI-compatible and routes requests to api.qnaigc.com. It supports chat completions and model listing APIs.

Files changed:

  • provider/qiniu.go: New provider implementation
  • provider/provider.go: Register qiniu provider type
  • test/qiniu.go: Unit tests for the Qiniu provider
  • main_test.go: Register TestQiniu test suite
  • README.md: Add Qiniu provider documentation and usage example

Ⅱ. Does this pull request fix one issue?

N/A

Ⅲ. Why don't you add test cases (unit test/integration test)?

Test cases are included. All tests pass:

  • RunQiniuParseConfigTests: config parsing validation
  • RunQiniuOnHttpRequestHeadersTests: request header transformation (Host, Authorization)
  • RunQiniuOnHttpRequestBodyTests: request body processing and model mapping

Ⅳ. Describe how to verify it

  1. Run unit tests:
cd plugins/wasm-go/extensions/ai-proxy
go test -v -run TestQiniu ./...
  1. Integration test with envoy.yaml (replace token with a valid Qiniu API token):
docker run --rm -it \
  -v $(pwd)/out/plugin.wasm:/etc/envoy/plugin.wasm \
  -v $(pwd)/envoy.yaml:/etc/envoy/envoy.yaml \
  -p 10000:10000 \
  --entrypoint /usr/local/bin/envoy \
  higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/gateway:latest \
  -c /etc/envoy/envoy.yaml

curl -X POST http://localhost:10000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-4", "messages": [{"role": "user", "content": "hello"}], "stream": false}'

Ⅴ. Special notes for reviews

The Qiniu provider follows the same pattern as other OpenAI-compatible providers. No special handling is needed — it simply rewrites the Host header to api.qnaigc.com and injects the Bearer token.

Ⅵ. AI Coding Tool Usage Checklist (if applicable)

Please check all applicable items:

  • For regular updates/changes (not new plugins):
    • [] I have provided the prompts/instructions I gave to the AI Coding tool below
    • [*] I have included the AI Coding summary below

AI Coding Prompts (for regular updates)

AI Coding Summary

Key decisions made:

  • Followed the existing OpenAI-compatible provider pattern (same as groq, fireworks, deepseek)
  • Used api.qnaigc.com as the provider domain
  • Registered capabilities for ChatCompletion and Models APIs only, as Qiniu's API is OpenAI-compatible

Major changes implemented:

  • New qiniuProvider struct implementing the Provider interface
  • TransformRequestHeaders: rewrites Host to api.qnaigc.com, injects Bearer token, removes Content-Length
  • ValidateConfig: requires at least one API token
  • Registered providerTypeQiniu = "qiniu" in the provider initializers map

Important considerations:

  • No custom request/response transformation needed; Qiniu's API is fully OpenAI-compatible

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