Welcome to Portkey Forum

Updated 3 weeks ago

Enabling multiple AI gateway features

Just a general question, consider the following request:
Plain Text
curl --request POST \
  --url https://api.portkey.ai/v1/chat/completions \
  --header 'Content-Type: application/json' \
  --header 'x-portkey-api-key: sxxx=' \
  --header 'x-portkey-config: {"retry":{"attempts":3},"cache":{"mode":"simple"},"strategy":{"mode":"loadbalance"},"targets":[{"virtual_key":"open-ai-kxey-","weight":0.7},{"virtual_key":"test-virtual-ke","weight":0.3}]}' \
  --header 'x-portkey-virtual-key: open-ai-key' \
  --data '{
    "model": "gpt-3.5-turbo",
    "messages": [
      { "role": "system", "content": "You are a helpful assistant." },
      { "role": "user", "content": "Hello!" }
    ]
  }'

As I can comprehend:
  • All requests will have automatic retries enabled, either it's load-balanced with model 1 or model 2
  • All requests will have simple cache enabled; either they are load-balanced with model 1 or model 2
  • The x-portkey-virtual-key will be ignored since x-portkey-config enabled.
  • Since model is mandatory property, and gpt-3.5-turbo is chosen model, do loadbalace targets should be same gpt-3.5-turbo models with different virtual keys? I suppose I am getting this bit wrong in my understanding?
S
V
6 comments
A follow-up question - can I add more targets ( how many max?) ? For example, 3 targets with distribution over 0.3, 0.4 and 0.3 ?
You can add upto 25 targets right now.
As I can comprehend:
Yes, you got it all right. For the last point, if both the virtual keys are OpenAI, then we will loadbalance on the given model name in data, which is gpt.3.5-turbo here. If the second target is not OpenAI and let's say a provider like Anyscale, and if you haven't given a specific model name with the override_params config, then we will pick a default model for that provider, which is llama-2-7b

Basically, override_params in the Config will override any value that you put in data. And if there are no override_params, then we will pick the default models for that provider
Let me know if that clarifies!
This clarifies. I request we put this up in documentation in some way or form, especially for loadbalance page. I'm open for contributions. Thanks once again for clarification. πŸŽ‰
Add a reply
Sign up and join the conversation on Discord