Skip to content

feat: add Avian as LLM provider#3369

Open
avianion wants to merge 6 commits into
simstudioai:mainfrom
avianion:feat/avian-provider
Open

feat: add Avian as LLM provider#3369
avianion wants to merge 6 commits into
simstudioai:mainfrom
avianion:feat/avian-provider

Conversation

@avianion
Copy link
Copy Markdown

Summary

Adds Avian as a new LLM provider. Avian is an OpenAI-compatible inference API offering competitive pricing on frontier models.

Models:

Model Context Window Input (per 1M) Output (per 1M)
deepseek/deepseek-v3.2 164K $0.26 $0.38
moonshotai/kimi-k2.5 131K $0.45 $2.20
z-ai/glm-5 131K $0.30 $2.55
minimax/minimax-m2.5 1M $0.30 $1.10

Features supported:

  • Chat completions
  • Streaming responses
  • Function/tool calling
  • Temperature control

Changes

  • components/icons.tsx — Add AvianIcon SVG component
  • providers/types.ts — Add 'avian' to ProviderId union type
  • providers/models.ts — Add Avian provider definition with model pricing and capabilities
  • providers/avian/index.ts — Provider implementation using OpenAI SDK (follows DeepSeek pattern)
  • providers/avian/utils.ts — Streaming utility using shared createOpenAICompatibleStream
  • providers/registry.ts — Register avianProvider in the provider registry
  • providers/utils.ts — Add Avian to provider metadata map

Implementation

The provider follows the same pattern as other OpenAI-compatible providers (DeepSeek, Cerebras). It uses the openai npm package with baseURL: 'https://api.avian.io/v1' and supports all standard features including tool calling loops, forced tool usage, and streaming with cost tracking.

Authentication is via user-provided API key (AVIAN_API_KEY as Bearer token).

Test plan

  • Verify Avian models appear in model selector dropdown
  • Test chat completion with deepseek/deepseek-v3.2 model
  • Test streaming response
  • Test function calling with a tool-enabled workflow
  • Verify cost tracking displays correct pricing

cc @waleedlatif1 @emir-karabeg

Add Avian (https://avian.io) as a new LLM provider with OpenAI-compatible
API support including chat completions, streaming, and function calling.

Models:
- deepseek/deepseek-v3.2 (164K context, $0.26/$0.38 per 1M tokens)
- moonshotai/kimi-k2.5 (131K context, $0.45/$2.20 per 1M tokens)
- z-ai/glm-5 (131K context, $0.30/$2.55 per 1M tokens)
- minimax/minimax-m2.5 (1M context, $0.30/$1.10 per 1M tokens)

Changes:
- Add AvianIcon to components/icons.tsx
- Add 'avian' to ProviderId type
- Add Avian provider definition with model pricing in models.ts
- Create providers/avian/ with index.ts and utils.ts
- Register provider in registry.ts and utils.ts
@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 27, 2026

@avianion is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 27, 2026

Greptile Summary

Added Avian as a new LLM provider with OpenAI-compatible API integration. The implementation follows the established DeepSeek provider pattern, reusing proven architecture for OpenAI SDK-based providers. The integration includes proper tool calling support, streaming responses, cost tracking, and provider metadata registration. All 4 models are correctly configured with pricing and context window specifications.

Confidence Score: 5/5

  • This PR is safe to merge with no concerns
  • The implementation is a well-executed pattern replication of the existing DeepSeek provider with appropriate naming changes. All imports follow established conventions, model definitions are accurate, and the provider is properly registered across all necessary files. No logic changes or risks introduced.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/providers/avian/index.ts New provider implementation following established DeepSeek pattern with OpenAI SDK, supports tool calling, streaming, and cost tracking
apps/sim/providers/models.ts Added Avian provider definition with 4 models, pricing, and configuration
apps/sim/providers/registry.ts Registered avianProvider in the provider registry map
apps/sim/providers/types.ts Added 'avian' to ProviderId union type
apps/sim/providers/utils.ts Added Avian to provider metadata map using buildProviderMetadata

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User selects Avian provider] --> B[Provider Registry]
    B --> C[avianProvider from /providers/avian/index.ts]
    C --> D[Initialize OpenAI SDK]
    D --> E[baseURL: api.avian.io/v1]
    E --> F{Request Type?}
    F -->|Streaming + No Tools| G[Create stream response]
    F -->|With Tools| H[Tool execution loop]
    F -->|Standard| I[Standard completion]
    H --> J[Execute tools with prepareToolsWithUsageControl]
    J --> K[Track forced tool usage]
    K --> L[Iterate up to MAX_TOOL_ITERATIONS]
    L --> M{Stream final?}
    M -->|Yes| G
    M -->|No| N[Return response with timing]
    G --> O[Calculate costs using model pricing]
    I --> O
    N --> O
    O --> P[Return to user with tokens & cost]
Loading

Last reviewed commit: f77f80c

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@avianion
Copy link
Copy Markdown
Author

avianion commented Mar 5, 2026

Friendly follow-up — this PR is still active and ready for review. Would appreciate a look when you get a chance! cc @waleedlatif1 @emir-karabeg

@avianion
Copy link
Copy Markdown
Author

avianion commented Mar 5, 2026

Friendly follow-up — this PR is still active and ready for review. All feedback has been addressed. Would appreciate a look when you get a chance! cc @waleedlatif1

@avianion
Copy link
Copy Markdown
Author

avianion commented Mar 5, 2026

Hey @waleedlatif1 @emir-karabeg — friendly follow-up on this PR. Avian is an OpenAI-compatible inference provider that's already live and powering apps like ISEKAI ZERO. This is a lightweight integration (standard OpenAI-compatible endpoint) and we're happy to address any feedback or make adjustments. Would love to get this merged if you have a moment to review. Thanks!

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cursor
Copy link
Copy Markdown

cursor Bot commented Mar 8, 2026

PR Summary

Medium Risk
Large new executor (~580 lines) on the inference path with tool loops and streaming, but it is additive and mirrors existing OpenAI-compatible providers rather than changing auth or shared security logic.

Overview
Adds Avian as a first-class LLM provider so workflows can call Avian’s OpenAI-compatible API (https://api.avian.io/v1) with user-supplied API keys.

The new avianProvider implements chat completions with streaming (no-tools path and post-tool final response), function/tool calling with usage control and forced-tool sequencing, token/cost tracking, and trace timing—aligned with other OpenAI-compatible providers (e.g. DeepSeek). A thin createReadableStreamFromAvianStream wraps the shared createOpenAICompatibleStream helper.

Catalog & UI wiring: ProviderId gains 'avian'; PROVIDER_DEFINITIONS lists four models (DeepSeek v3.2, Kimi K2.5, GLM-5, MiniMax M2.5) with pricing, context windows, and toolUsageControl; AvianIcon is added; the provider is registered in registry.ts and client metadata in providers/utils.ts.

Reviewed by Cursor Bugbot for commit f885d73. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jun 5, 2026 10:44am

Request Review

})
}
},
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

~560-line provider duplicates DeepSeek implementation verbatim

Low Severity

The entire avian/index.ts (~560 lines) is a near-verbatim copy of deepseek/index.ts, differing only in the provider name string and base URL. The avian/utils.ts wrapper is also a trivial one-liner delegating to createOpenAICompatibleStream, identical in structure to deepseek/utils.ts, groq/utils.ts, etc. Given that a shared createOpenAICompatibleStream utility and checkForForcedToolUsageOpenAI helper already exist in providers/utils.ts, this full duplication increases maintenance burden — any future bug fix to the tool-calling loop, streaming, or cost tracking logic needs to be replicated across every copy-pasted provider.

Additional Locations (1)

Fix in Cursor Fix in Web

@avianion
Copy link
Copy Markdown
Author

Re: Bugbot feedback on ~560-line duplication with DeepSeek

Investigated the duplication concern. The Avian provider is indeed a near-verbatim copy of DeepSeek (only the provider name and base URL differ), but this is the established pattern across the entire codebase — every OpenAI-compatible provider (DeepSeek, Groq, xAI, Mistral, Cerebras, OpenRouter) maintains its own full copy of the same ~550-line implementation:

Provider Lines
DeepSeek 561
Groq 519
xAI 611
Mistral 574
Cerebras 561
OpenRouter 621
Avian 561

There is no shared createOpenAICompatibleProvider factory in this codebase. Creating one would be a worthwhile refactor, but it would be a cross-cutting change touching 7+ providers and is well outside the scope of this PR. Introducing it just for Avian would create an inconsistency where one provider uses an abstraction and six others don't.

The Avian implementation correctly follows the existing pattern, uses the shared utilities that do exist (createOpenAICompatibleStream, prepareToolsWithUsageControl, trackForcedToolUsage, calculateCost), and matches DeepSeek's proven implementation exactly. No refactoring applied.

@avianion
Copy link
Copy Markdown
Author

avianion commented Apr 7, 2026

Addressed the review feedback:

  1. SVG icon: Replaced with a self-contained SVG using only inline path data — no external references, no embedded base64 images.

  2. Provider implementation: Updated to match the current pattern on main — added sumToolCosts import, typed toolResults as Record<string, unknown>[], added toolCost field to cost tracking, and fixed the result.success && result.output guard. Merged upstream main to resolve conflicts.

  3. Lint/formatting: Ran biome check and fixed formatting issues (callback argument placement in streaming functions). All files now pass biome check cleanly.

@avianion
Copy link
Copy Markdown
Author

avianion commented Apr 8, 2026

Addressed feedback: confirmed no dead code paths in the Avian provider — the implementation only handles text model completions with no unreachable branches. Reviewed all provider logic; the current code correctly returns text responses directly without any image-handling dead code.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 3 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7d94f16. Configure here.

Comment thread apps/sim/providers/avian/index.ts Outdated
Comment thread apps/sim/providers/avian/index.ts
@avianion
Copy link
Copy Markdown
Author

avianion commented Jun 5, 2026

Addressed feedback: fixed abort signal propagation and trace enrichment in tool-calling loop

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