Skip to content

feat: add Avian as LLM provider#494

Open
avianion wants to merge 2 commits intoCodebuffAI:mainfrom
avianion:feat/add-avian-provider
Open

feat: add Avian as LLM provider#494
avianion wants to merge 2 commits intoCodebuffAI:mainfrom
avianion:feat/add-avian-provider

Conversation

@avianion
Copy link
Copy Markdown

@avianion avianion commented Apr 4, 2026

Summary

  • Add Avian as a new OpenAI-compatible LLM provider (https://api.avian.io/v1)
  • New provider module (web/src/llm-api/avian.ts) following the same pattern as Fireworks/SiliconFlow, with streaming + non-streaming support, per-model pricing, usage/billing tracking, TTFT measurement, and error handling
  • Route avian/* model IDs through the Avian provider in the chat completions API
  • Add AVIAN_API_KEY to server env schema (optional, like other third-party provider keys)
  • Register Avian models in model-config.ts constants, providerModelNames, providerDomains, and all three copies of the ModelName type

Models available via Avian

Model Context Input Output
avian/deepseek-v3.2 164K $0.14/M $0.28/M
avian/kimi-k2.5 128K $0.14/M $0.28/M
avian/glm-5 128K $0.25/M $0.50/M
avian/minimax-m2.5 1M $0.15/M $0.30/M

Test plan

  • Verify isAvianModel() correctly matches only avian/* model IDs
  • Test streaming and non-streaming requests route to Avian when model starts with avian/
  • Confirm billing/credit consumption works correctly with Avian pricing
  • Verify AvianError is caught and returned with proper status codes
  • Check that non-Avian models still route to their existing providers (no regression)

Add Avian (api.avian.io) as a new OpenAI-compatible inference provider with
four models: DeepSeek V3.2, Kimi K2.5, GLM-5, and MiniMax M2.5.

Changes:
- New provider module (web/src/llm-api/avian.ts) with streaming and
  non-streaming support, per-model pricing, usage tracking, and billing
- Route avian/* models through the Avian provider in chat completions API
- Add AVIAN_API_KEY to server env schema
- Register avian models in model-config constants and agent type definitions
Copy link
Copy Markdown
Contributor

hiSandog commented Apr 9, 2026

One thing I'd double-check before merging: web/src/llm-api/avian.ts currently bills as soon as any streamed chunk contains usage. In this repo, the newer provider implementations in web/src/llm-api/canopywave.ts and web/src/llm-api/siliconflow.ts added a billedAlready + isFinalChunk(...) guard because some providers emit cumulative usage on non-final chunks or can repeat a terminal usage frame.

Without that guard here, Avian could insert duplicate BigQuery rows and consume credits more than once for the same response. I'd be inclined to copy the CanopyWave/SiliconFlow pattern and strip usage from non-final chunks before forwarding them to the SDK.

@avianion
Copy link
Copy Markdown
Author

avianion commented Apr 9, 2026

Addressed feedback: added billedAlready + isFinalChunk() guard to prevent duplicate BigQuery rows and credit charges. Follows the same pattern used in canopywave.ts and siliconflow.ts — usage is now stripped from non-final chunks and billing only triggers once on the final chunk with finish_reason.

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