Skip to content

feat: add FriendliAI provider with auto-sync from serverless API - #871

Open
Lee-Si-Yoon wants to merge 3 commits into
Portkey-AI:mainfrom
Lee-Si-Yoon:feat/friendli-provider
Open

feat: add FriendliAI provider with auto-sync from serverless API#871
Lee-Si-Yoon wants to merge 3 commits into
Portkey-AI:mainfrom
Lee-Si-Yoon:feat/friendli-provider

Conversation

@Lee-Si-Yoon

Copy link
Copy Markdown

Summary

Adds FriendliAI as a new provider, with an automated sync script that fetches model metadata from the Friendli serverless API.

Companion to gateway PR #1756 which registers the friendli provider in the gateway.

Changes

  • general/friendli.json — Model capabilities (max_tokens, tools/image support) with Friendli-specific params: chat_template_kwargs, parse_reasoning, include_reasoning (reasoning controls for models like GLM-5.2)
  • pricing/friendli.json — Per-model pricing (USD/token → cents/token ×100), including cache_read_input_token where available
  • scripts/sync-friendli-models.js — Fetches https://api.friendli.ai/serverless/v1/models and regenerates both JSON files. Supports --dry-run, retries on 503
  • README.md — Added FriendliAI to the providers list
  • scripts/README.md — Documented the new sync script

Pricing Unit Conversion

The Friendli API returns prices in USD/token. This repo stores prices in cents/token, so the script multiplies by 100:

Model API (USD/tok) Repo (¢/tok)
zai-org/GLM-5.2 input 0.0000014 0.00014
zai-org/GLM-5.2 output 0.0000044 0.00044
zai-org/GLM-5.2 cache read 0.00000026 0.000026

Verification

  • npm run lint — passes
  • npx prettier --check — all files formatted
  • python3 scripts/check_duplicate_keys.py — no duplicate keys
  • node scripts/sync-friendli-models.js — generates valid JSON from live API
  • node scripts/sync-friendli-models.js --dry-run — preview works

Currently Synced Models (6)

  • deepseek-ai/DeepSeek-V3.2
  • google/gemma-4-31B-it
  • LGAI-EXAONE/K-EXAONE-236B-A23B
  • MiniMaxAI/MiniMax-M2.5
  • zai-org/GLM-5.1
  • zai-org/GLM-5.2

Usage

# Regenerate both JSON files from the live API
node scripts/sync-friendli-models.js

# Preview without writing
node scripts/sync-friendli-models.js --dry-run

Adds general/friendli.json and pricing/friendli.json generated from the
FriendliAI serverless API (https://api.friendli.ai/serverless/v1/models).

- general/friendli.json: model capabilities (max_tokens, tools, image)
  with Friendli-specific params (reasoning controls: chat_template_kwargs,
  parse_reasoning, include_reasoning)
- pricing/friendli.json: per-model pricing (USD/token → cents/token ×100)
  including cache_read_input_token where available
- scripts/sync-friendli-models.js: fetches the live model list and
  regenerates both JSON files; supports --dry-run; retries on 503
- README.md: add FriendliAI to the providers list

Companion to gateway PR #1756 (provider registration as 'friendli').
Replace the placeholder params with proper OpenAI-compatible params from
the Friendli OpenAPI spec (ServerlessChatCompletionBody):
- default: max_tokens, temperature, top_p, top_k, frequency_penalty,
  presence_penalty, repetition_penalty, n, stop, stream
- tool-capable models: tool_choice + response_format (json_object/json_schema)

Friendli-specific reasoning controls (chat_template_kwargs, parse_reasoning,
include_reasoning, reasoning_effort, reasoning_budget) are handled by the
gateway provider adapter (PR #1756), not the models repo general config.

Source: https://github.com/friendliai/friendli-openapi
- max_tokens: per-model maxValue from API max_completion_tokens (163K-1M),
  no global maxValue 4096
- temperature/top_k/repetition_penalty/n: defaultValue from API
  default_params, no fabricated minValue/maxValue
- top_p (0-1), frequency_penalty (-2..2), presence_penalty (-2..2),
  min_p (0-1): ranges from Friendli OpenAPI spec descriptions
- Added min_p param (present in API default_params, documented in spec)
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