Skip to content

Add FlexAI as an AI Gateway provider - #5830

Open
sundar-flex wants to merge 4 commits into
Helicone:mainfrom
sundar-flex:add-flexai-provider
Open

sundar-flex wants to merge 4 commits into
Helicone:mainfrom
sundar-flex:add-flexai-provider

Conversation

@sundar-flex

@sundar-flex sundar-flex commented Oct 3, 2026 •

Copy link
Copy Markdown

Adds FlexAI (https://flex.ai) as an AI Gateway provider, following INTEGRATE_PROVIDER_TO_GATEWAY.md.

FlexAI is an OpenAI-compatible inference provider serving open-weight models. This PR registers the provider and adds endpoints for the six models FlexAI serves that already have a model definition in this registry — no new authors or model families, so nothing in the catalogue had to be invented.

Provider

Base URL https://api.flex.ai/ → v1/chat/completions
Auth Authorization: Bearer <key> (auth: "api-key", no override needed)
Pricing page https://flex.ai/pricing
Models page https://flex.ai/models
Priority 4 (default third-party)
PTB ptbEnabled: false on every endpoint — BYOK only

Endpoints added

Every value below was measured against the live API on 2026-10-02, not copied from a listing.

Endpoint key providerModelId input $/M output $/M ctx / max out quant tools
gpt-oss-120b:flexai gpt-oss-120b 0.03 0.17 131072 fp4 yes
gpt-oss-20b:flexai gpt-oss-20b 0.02 0.10 131072 fp4 yes
llama-3.1-8b-instruct:flexai Meta-Llama-3.1-8B-Instruct-FP8 0.02 0.05 131072 fp8 yes
llama-3.3-70b-instruct:flexai Llama-3.3-70B-Instruct-FP8 0.135 0.40 131072 fp8 yes
mistral-nemo:flexai Mistral-Nemo-Instruct-2407-FP8 0.019 0.03 131072 fp8 yes
qwen3-coder-30b-a3b-instruct:flexai Qwen3-Coder-30B-A3B-Instruct-FP8 0.07 0.26 262144 fp8 yes

How the values were verified

Prices come from FlexAI's own GET /v1/models (pricing.input_per_mtok / output_per_mtok), and were then reconciled against billed cost on a live completion:

  • gpt-oss-120b: prompt_tokens: 74, of which cached_tokens: 64; reported upstream_inference_prompt_cost: 5.9e-07. Hand-computed with cached tokens inside prompt_tokens and billed at the published cached rate: (74−64)×3e-8 + 64×4.5e-9 = 5.88e-07. ✅
  • Llama-3.3-70B-Instruct-FP8: prompt_tokens: 42, cached_tokens: 16, reported 3.83e-06. (42−16)×1.35e-7 + 16×2.03e-8 = 3.835e-06. ✅

That reconciliation establishes two things the price table alone doesn't: cached tokens are counted inside prompt_tokens (so the registry's cache handling is correct), and the published cached rate is 0.15 × input on every model — hence cacheMultipliers: { cachedInput: 0.15 } on each endpoint.

Context / max output. /v1/models reports max_output_length equal to context_length on every row, which on its own would be an unverified claim, so the ceiling was probed directly. The API rejects max_tokens strictly greater than the context window ("max_tokens=131073 cannot be greater than the model's maximum context length of 131072 tokens"), so maxCompletionTokens is set equal to contextLength, which is the measured limit.

supportedParameters is the intersection of FlexAI's per-model supported_parameters with this repo's StandardParameter union. The one exception: Llama-3.3-70B-Instruct-FP8 omits min_p and logit_bias. FlexAI serves it with speculative decoding, which rejects both with a 400 even though /v1/models lists them (verified live 2026-10-06).

One correction worth flagging: FlexAI's /v1/models metadata does not list tool_use for Mistral-Nemo-Instruct-2407-FP8, but the deployment emits a well-formed get_weather tool call on two independent live requests (finish_reason: "tool_calls"). The measurement is what's declared here, and tools / tool_choice are included for it.

Two things were deliberately left out rather than guessed:

  • rateLimits — FlexAI publishes a per-account request-rate limit, not the per-model tpm/tpd shape this field wants, so declaring numbers here would be fiction.
  • Models with no existing definition in the registry (FlexAI also serves GLM, DeepSeek V4, Qwen 3.5/3.6/3.8, Gemma 4, Nemotron, MiniMax, Step, embeddings, image, ASR and TTS models). Adding those means adding model families, which belongs in a separate PR rather than being smuggled into a provider registration.

Qwen3-30B-A3B-Thinking-2507 is served by FlexAI but is not mapped onto this registry's qwen3-30b-a3b (41k context, non-thinking Instruct weights) — a different model, so it is omitted rather than mis-attached.

Registration points touched

Found by grepping an existing comparable provider (canopywave, deepinfra) repo-wide and diffing the commit that added Canopy Wave (#5292):

  1. packages/cost/models/providers/flexai.ts — provider class
  2. packages/cost/models/providers/index.ts — import, registry entry, ResponsesAPIEnabledProviders (chat-completions-only group; BaseProvider.buildRequestBody already maps RESPONSES → chat completions)
  3. packages/cost/models/providers/priorities.ts
  4. packages/cost/providers/mappings.ts — URL pattern, providersNames, provider row
  5. packages/cost/models/provider-helpers.ts — heliconeProviderToModelProviderName, dbProviderToProvider
  6. packages/cost/usage/getUsageProcessor.ts — OpenAI usage processor
  7. web/data/providers.ts + web/public/assets/home/providers/flexai.webp (512×512, from FlexAI's brand mark)
  8. endpoints in four existing author families
  9. worker/test/setup.ts provider-key fixtures (both BYOK and Helicone-key blocks)
  10. worker/test/ai-gateway/registry-{openai,meta-llama,mistralai,alibaba}.spec.ts
  11. packages/__tests__/cost/__snapshots__/registrySnapshots.test.ts.snap — regenerated with npx jest --updateSnapshot (step 9 of the guide)

Checks run

Baseline measured on untouched main in the same install, then re-run on this branch.

Command main this branch
npx vitest run test/ai-gateway/registry-{openai,meta-llama,mistralai,alibaba}.spec.ts (worker) 4 files, 628 passed, 0 failed 4 files, 644 passed, 0 failed (+16 new, and registry-mistralai alone re-run after the tool-call fix: 101 passed)
npx jest __tests__/ (packages) 41 passed / 1 skipped, 578 passed 41 passed / 1 skipped, 578 passed, 8 snapshots passed
npx tsc --noEmit (worker) exit 0 exit 0

Snapshot delta is exactly what you'd expect: totalProviders 21 → 22, totalEndpoints 329 → 335, { provider: "flexai", modelCount: 6 }.

Not verified

The gateway was not exercised end-to-end against the live FlexAI API — the registry and worker test suites use mocked upstreams, and I have no Helicone deployment to route a real request through. Everything above the transport (URL construction, auth header shape, prices, context, parameters, tool calls) was measured directly against api.flex.ai.

Happy to adjust naming, priority, or the endpoint set.

🤖 Generated with Claude Code

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@vercel

vercel Bot commented Oct 3, 2026

Copy link
Copy Markdown

@sundar-flex is attempting to deploy a commit to the Helicone Team on Vercel.

A member of the Team first needs to authorize it.

@cursor

cursor Bot commented Oct 6, 2026

Copy link
Copy Markdown

Bugbot is paused — on-demand spend limit reached

Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

sundar-flex and others added 3 commits October 22, 2026 18:27
FlexAI (https://flex.ai) is an OpenAI-compatible inference provider.
This registers it in the gateway registry and adds endpoints for the six
models it serves that already have a model definition in the registry.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
FlexAI now serves Llama-3.3-70B-Instruct-FP8 with speculative decoding,
which rejects both parameters with a 400 ("The min_p and logit_bias
sampling parameters are not yet supported with speculative decoding").
Verified live 2026-10-06; the other five FlexAI endpoints still accept
both. Registry snapshot updated to match.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Upstream's vault-key hardening requires every AI Gateway provider to declare
its first-party origins (firstPartyOrigins.test.ts).
@cursor

cursor Bot commented Oct 23, 2026

Copy link
Copy Markdown

Bugbot is paused — your team has an unpaid invoice

Bugbot is paused because your team has an unpaid invoice.

Pay it from the billing page in the Cursor dashboard and Bugbot resumes automatically.

(requestId: 8bedc825-6029-4d14-a820-3c8ea8481f9c)

Update FlexAI endpoint pricing to the current published rates
(https://flex.ai/pricing):
- gpt-oss-120b: $0.05 / $0.25 per 1M (was $0.03 / $0.17)
- llama-3.3-70b-instruct: $0.22 / $0.50 (was $0.135 / $0.40)
- qwen3-coder-30b-a3b-instruct: output $0.28 (was $0.26)
- mistral-nemo: input $0.023 (was $0.019)

Cached input stays at the 0.15x multiplier, which matches the
published cached-input rate. Registry snapshot regenerated.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@cursor

cursor Bot commented Oct 23, 2026

Copy link
Copy Markdown

Bugbot is paused — your team has an unpaid invoice

Bugbot is paused because your team has an unpaid invoice.

Pay it from the billing page in the Cursor dashboard and Bugbot resumes automatically.

(requestId: 54009ad1-3542-42e6-b5ad-6997b0685aee)

This branch has not been deployed

No deployments
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