Skip to content

Commit ccf68f9

Browse files
Merge pull request #117 from Portkey-AI/feat/models-openapi
feat: add model pricing endpoint and related schemas
2 parents c0c6ece + daa850b commit ccf68f9

1 file changed

Lines changed: 292 additions & 0 deletions

File tree

openapi.yaml

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ x-server-groups:
2323
- url: SELF_HOSTED_GATEWAY_URL
2424
description: Self-Hosted Gateway URL
2525

26+
PublicServers: &PublicServers
27+
- url: https://api.portkey.ai
28+
description: Portkey Public API (no auth required)
29+
2630
x-mint:
2731
mcp:
2832
enabled: true
@@ -110,6 +114,8 @@ tags:
110114
description: Manage usage limits policies to control total usage over time
111115
- name: Rate Limits Policies
112116
description: Manage rate limits policies to control request or token rates
117+
- name: Model Pricing
118+
description: Model pricing configurations for 2300+ LLMs across 40+ providers
113119

114120

115121
paths:
@@ -19425,6 +19431,165 @@ paths:
1942519431
- object
1942619432
- data
1942719433

19434+
/model-configs/pricing/{provider}/{model}:
19435+
servers: *PublicServers
19436+
get:
19437+
summary: Get Model Pricing
19438+
security: []
19439+
description: |
19440+
Returns pricing configuration for a specific model.
19441+
19442+
**Note:** Prices are in USD cents per token.
19443+
19444+
## Supported Providers
19445+
19446+
openai, anthropic, google, azure-openai, bedrock, mistral-ai, cohere,
19447+
together-ai, groq, deepseek, fireworks-ai, perplexity-ai, anyscale,
19448+
deepinfra, cerebras, x-ai, and 25+ more.
19449+
19450+
## Example Response Fields
19451+
19452+
| Field | Description | Unit |
19453+
|-------|-------------|------|
19454+
| `request_token.price` | Input token cost | cents/token |
19455+
| `response_token.price` | Output token cost | cents/token |
19456+
| `cache_write_input_token.price` | Cache write cost | cents/token |
19457+
| `cache_read_input_token.price` | Cache read cost | cents/token |
19458+
| `additional_units.*` | Provider-specific features | cents/unit |
19459+
19460+
operationId: getModelPricing
19461+
tags:
19462+
- Model Pricing
19463+
parameters:
19464+
- name: provider
19465+
in: path
19466+
required: true
19467+
description: |
19468+
Provider identifier. Use lowercase with hyphens.
19469+
19470+
Examples: `openai`, `anthropic`, `google`, `azure-openai`, `bedrock`, `x-ai`
19471+
schema:
19472+
type: string
19473+
example: openai
19474+
- name: model
19475+
in: path
19476+
required: true
19477+
description: |
19478+
Model identifier. Use the exact model name as specified by the provider.
19479+
19480+
Examples: `gpt-5`, `gpt-5.2`, `claude-opus-4-5-20251101`, `gemini-3.0-pro`
19481+
schema:
19482+
type: string
19483+
example: gpt-5
19484+
responses:
19485+
'200':
19486+
description: Pricing configuration for the specified model
19487+
content:
19488+
application/json:
19489+
schema:
19490+
$ref: '#/components/schemas/ModelPricingConfig'
19491+
examples:
19492+
openai-gpt4:
19493+
summary: OpenAI GPT-4
19494+
value:
19495+
pay_as_you_go:
19496+
request_token:
19497+
price: 0.003
19498+
response_token:
19499+
price: 0.006
19500+
calculate:
19501+
request:
19502+
operation: sum
19503+
operands:
19504+
- operation: multiply
19505+
operands:
19506+
- value: input_tokens
19507+
- value: rates.request_token
19508+
- operation: multiply
19509+
operands:
19510+
- value: cache_write_tokens
19511+
- value: rates.cache_write_input_token
19512+
- operation: multiply
19513+
operands:
19514+
- value: cache_read_tokens
19515+
- value: rates.cache_read_input_token
19516+
response:
19517+
operation: multiply
19518+
operands:
19519+
- value: output_tokens
19520+
- value: rates.response_token
19521+
currency: USD
19522+
openai-gpt4o-with-tools:
19523+
summary: OpenAI GPT-4o (with additional units)
19524+
value:
19525+
pay_as_you_go:
19526+
request_token:
19527+
price: 0.00025
19528+
response_token:
19529+
price: 0.001
19530+
cache_write_input_token:
19531+
price: 0
19532+
cache_read_input_token:
19533+
price: 0.000125
19534+
additional_units:
19535+
web_search:
19536+
price: 1
19537+
file_search:
19538+
price: 0.25
19539+
calculate:
19540+
request:
19541+
operation: sum
19542+
operands:
19543+
- operation: multiply
19544+
operands:
19545+
- value: input_tokens
19546+
- value: rates.request_token
19547+
response:
19548+
operation: multiply
19549+
operands:
19550+
- value: output_tokens
19551+
- value: rates.response_token
19552+
currency: USD
19553+
anthropic-claude:
19554+
summary: Anthropic Claude 3.5 Sonnet
19555+
value:
19556+
pay_as_you_go:
19557+
request_token:
19558+
price: 0.0003
19559+
response_token:
19560+
price: 0.0015
19561+
cache_read_input_token:
19562+
price: 0.00003
19563+
cache_write_input_token:
19564+
price: 0.000375
19565+
currency: USD
19566+
google-gemini:
19567+
summary: Google Gemini 2.5 Pro (with thinking tokens)
19568+
value:
19569+
pay_as_you_go:
19570+
request_token:
19571+
price: 0.000125
19572+
response_token:
19573+
price: 0.001
19574+
additional_units:
19575+
thinking_token:
19576+
price: 0.001
19577+
web_search:
19578+
price: 3.5
19579+
search:
19580+
price: 3.5
19581+
currency: USD
19582+
'404':
19583+
description: Model or provider not found
19584+
content:
19585+
application/json:
19586+
schema:
19587+
type: object
19588+
properties:
19589+
error:
19590+
type: string
19591+
example: Model not found
19592+
1942819593

1942919594
components:
1943019595
securitySchemes:
@@ -19711,6 +19876,133 @@ components:
1971119876
type: string
1971219877

1971319878
schemas:
19879+
ModelPricingConfig:
19880+
type: object
19881+
description: Complete pricing configuration for a model
19882+
properties:
19883+
pay_as_you_go:
19884+
$ref: '#/components/schemas/ModelPayAsYouGo'
19885+
calculate:
19886+
$ref: '#/components/schemas/ModelCalculateConfig'
19887+
currency:
19888+
type: string
19889+
enum: [USD]
19890+
description: Currency code (always USD)
19891+
finetune_config:
19892+
$ref: '#/components/schemas/ModelFinetuneConfig'
19893+
19894+
ModelPayAsYouGo:
19895+
type: object
19896+
description: Token-based pricing (all prices in USD cents)
19897+
properties:
19898+
request_token:
19899+
$ref: '#/components/schemas/ModelTokenPrice'
19900+
response_token:
19901+
$ref: '#/components/schemas/ModelTokenPrice'
19902+
cache_write_input_token:
19903+
$ref: '#/components/schemas/ModelTokenPrice'
19904+
cache_read_input_token:
19905+
$ref: '#/components/schemas/ModelTokenPrice'
19906+
request_audio_token:
19907+
$ref: '#/components/schemas/ModelTokenPrice'
19908+
response_audio_token:
19909+
$ref: '#/components/schemas/ModelTokenPrice'
19910+
cache_read_audio_input_token:
19911+
$ref: '#/components/schemas/ModelTokenPrice'
19912+
additional_units:
19913+
type: object
19914+
description: |
19915+
Provider-specific additional pricing units.
19916+
19917+
Common additional units:
19918+
- `web_search`: Web search tool usage
19919+
- `file_search`: File search tool usage
19920+
- `thinking_token`: Chain-of-thought reasoning tokens (Google)
19921+
- `image_token`: Image generation tokens
19922+
- `video_duration_seconds_*`: Video generation (OpenAI Sora)
19923+
additionalProperties:
19924+
$ref: '#/components/schemas/ModelTokenPrice'
19925+
image:
19926+
$ref: '#/components/schemas/ModelImagePricing'
19927+
19928+
ModelTokenPrice:
19929+
type: object
19930+
description: Price object (value is in USD cents)
19931+
properties:
19932+
price:
19933+
type: number
19934+
description: |
19935+
Price in USD cents per token/unit.
19936+
19937+
Example: `0.003` = 0.003 cents/token = $0.03 per 1K tokens
19938+
19939+
ModelImagePricing:
19940+
type: object
19941+
description: Image generation pricing by quality and size
19942+
additionalProperties:
19943+
type: object
19944+
additionalProperties:
19945+
$ref: '#/components/schemas/ModelTokenPrice'
19946+
example:
19947+
standard:
19948+
1024x1024:
19949+
price: 4
19950+
1024x1792:
19951+
price: 8
19952+
hd:
19953+
1024x1024:
19954+
price: 8
19955+
1024x1792:
19956+
price: 12
19957+
19958+
ModelCalculateConfig:
19959+
type: object
19960+
description: Cost calculation formulas
19961+
properties:
19962+
request:
19963+
$ref: '#/components/schemas/ModelCalculateOperation'
19964+
response:
19965+
$ref: '#/components/schemas/ModelCalculateOperation'
19966+
19967+
ModelCalculateOperation:
19968+
type: object
19969+
description: Mathematical operation for cost calculation
19970+
properties:
19971+
operation:
19972+
type: string
19973+
enum: [sum, multiply]
19974+
description: Operation type
19975+
operands:
19976+
type: array
19977+
description: Operands for the operation
19978+
items:
19979+
oneOf:
19980+
- $ref: '#/components/schemas/ModelCalculateOperation'
19981+
- $ref: '#/components/schemas/ModelValueReference'
19982+
19983+
ModelValueReference:
19984+
type: object
19985+
properties:
19986+
value:
19987+
type: string
19988+
description: |
19989+
Reference to a value or rate.
19990+
19991+
Examples:
19992+
- `input_tokens`: Number of input tokens
19993+
- `output_tokens`: Number of output tokens
19994+
- `rates.request_token`: Request token rate
19995+
- `rates.response_token`: Response token rate
19996+
19997+
ModelFinetuneConfig:
19998+
type: object
19999+
description: Fine-tuning pricing configuration
20000+
properties:
20001+
pay_per_token:
20002+
$ref: '#/components/schemas/ModelTokenPrice'
20003+
pay_per_hour:
20004+
$ref: '#/components/schemas/ModelTokenPrice'
20005+
1971420006
Error:
1971520007
type: object
1971620008
properties:

0 commit comments

Comments
 (0)