Skip to content

Commit 970bd4f

Browse files
Merge pull request #95 from Portkey-AI/chore/add-models-endpoint
models enpdoint
2 parents bdc2d52 + 715cc20 commit 970bd4f

File tree

1 file changed

+112
-27
lines changed

1 file changed

+112
-27
lines changed

openapi.yaml

Lines changed: 112 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4636,65 +4636,150 @@ paths:
46364636
main();
46374637

46384638
/models:
4639+
servers: *DataPlaneServers
46394640
get:
46404641
operationId: listModels
46414642
tags:
46424643
- Models
4643-
summary: Lists the currently available models, and provides basic information about each one such as the owner and availability.
4644+
summary: List Available Models
4645+
description: >-
4646+
Lists the currently available models that can be used through Portkey, and provides basic information about each one.
4647+
parameters:
4648+
- in: query
4649+
name: ai_service
4650+
required: false
4651+
description: Filter models by the AI service (e.g., 'openai', 'anthropic').
4652+
schema:
4653+
type: string
4654+
- in: query
4655+
name: provider
4656+
required: false
4657+
description: Filter models by the provider.
4658+
schema:
4659+
type: string
4660+
- in: query
4661+
name: limit
4662+
required: false
4663+
description: The maximum number of models to return.
4664+
schema:
4665+
type: integer
4666+
- in: query
4667+
name: offset
4668+
required: false
4669+
description: The number of models to skip before starting to collect the result set.
4670+
schema:
4671+
type: integer
4672+
- in: query
4673+
name: sort
4674+
required: false
4675+
description: The field to sort the results by.
4676+
schema:
4677+
type: string
4678+
enum: [name, provider, ai_service]
4679+
default: name
4680+
- in: query
4681+
name: order
4682+
required: false
4683+
description: The order to sort the results in.
4684+
schema:
4685+
type: string
4686+
enum: [asc, desc]
4687+
default: asc
46444688
responses:
4645-
"200":
4689+
'200':
46464690
description: OK
46474691
content:
46484692
application/json:
46494693
schema:
4650-
$ref: "#/components/schemas/ListModelsResponse"
4651-
4694+
$ref: '#/components/schemas/ListModelsResponse'
4695+
example:
4696+
object: "list"
4697+
total: 500
4698+
data:
4699+
- id: "@ai-provider-slug/gpt-5"
4700+
slug: "gpt-5"
4701+
canonical_slug: "gpt-5"
4702+
object: "model"
46524703
security:
46534704
- Portkey-Key: []
4654-
Virtual-Key: []
4655-
- Portkey-Key: []
4656-
Provider-Auth: []
4657-
Provider-Name: []
4658-
- Portkey-Key: []
4659-
Config: []
4660-
- Portkey-Key: []
4661-
Provider-Auth: []
4662-
Provider-Name: []
4663-
Custom-Host: []
4664-
46654705
x-code-samples:
46664706
- lang: curl
4707+
label: Default
46674708
source: |
4668-
curl https://api.portkey.ai/v1/models \
4669-
-H "x-portkey-api-key: $PORTKEY_API_KEY" \
4670-
-H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY"
4709+
# Example of sending a query parameter in the URL
4710+
curl 'https://api.portkey.ai/v1/models?provider=openai' \
4711+
-H "x-portkey-api-key: $PORTKEY_API_KEY"
4712+
- lang: curl
4713+
label: Self-Hosted
4714+
source: |
4715+
# Example of sending a query parameter in the URL
4716+
curl 'https://YOUR_SELF_HOSTED_URL/models?provider=openai' \
4717+
-H "x-portkey-api-key: $PORTKEY_API_KEY"
4718+
- lang: python
4719+
label: Default
4720+
source: |
4721+
from portkey_ai import Portkey
4722+
4723+
client = Portkey(
4724+
api_key = "PORTKEY_API_KEY"
4725+
)
4726+
4727+
# Example of sending query parameters via extra_query
4728+
models = client.models.list(
4729+
extra_query={"provider": "openai"}
4730+
)
4731+
print(models)
46714732
- lang: python
4733+
label: Self-Hosted
46724734
source: |
46734735
from portkey_ai import Portkey
46744736

46754737
client = Portkey(
46764738
api_key = "PORTKEY_API_KEY",
4677-
virtual_key = "PROVIDER_VIRTUAL_KEY"
4739+
base_url = "https://YOUR_SELF_HOSTED_URL"
4740+
)
4741+
4742+
# Example of sending query parameters via extra_query
4743+
models = client.models.list(
4744+
extra_query={"provider": "openai"}
46784745
)
4746+
print(models)
4747+
- lang: javascript
4748+
label: Default
4749+
source: |
4750+
import Portkey from 'portkey-ai';
46794751

4680-
client.models.list()
4752+
const client = new Portkey({
4753+
apiKey: 'PORTKEY_API_KEY'
4754+
});
4755+
4756+
async function main() {
4757+
// Example of sending query parameters in the list method
4758+
const list = await client.models.list({
4759+
provider: "openai"
4760+
});
4761+
console.log(list);
4762+
}
4763+
main();
46814764
- lang: javascript
4765+
label: Self-Hosted
46824766
source: |
46834767
import Portkey from 'portkey-ai';
46844768

46854769
const client = new Portkey({
46864770
apiKey: 'PORTKEY_API_KEY',
4687-
virtualKey: 'PROVIDER_VIRTUAL_KEY'
4771+
baseUrl: 'https://YOUR_SELF_HOSTED_URL'
46884772
});
46894773

46904774
async function main() {
4691-
const list = await client.models.list();
4692-
4693-
for await (const model of list) {
4694-
console.log(model);
4695-
}
4775+
// Example of sending query parameters in the list method
4776+
const list = await client.models.list({
4777+
provider: "openai"
4778+
});
4779+
console.log(list);
46964780
}
4697-
main();
4781+
main();
4782+
46984783

46994784
/models/{model}:
47004785
get:

0 commit comments

Comments
 (0)