Welcome to Portkey Forum

Updated 6 months ago

@Vrushank | Portkey

@Vrushank | Portkey
OK, so I didn't get an error now when creating the Porkey instance and passing a dummy. But my completion request is still failing:
Plain Text
completion = portkey.chat.completions.create(messages = [{ "role": 'user', "content": 'Say this is a test' }])

ValidationError: 1 validation error for ChatCompletions
choices
  field required (type=value_error.missing)
V
a
8 comments
What's in your print statement?
you mean the log in the gateway proxy?

Plain Text
Tried undefined time(s) but failed. Error: {"cause":{"errno":-3008,"code":"ENOTFOUND","syscall":"getaddrinfo","hostname":"MY AZURE endpoint url"}}
@Vrushank | Portkey
I will also write the censored valuges for the args I'm using to create the Portkey instance:

Plain Text
portkey = Portkey(provider = "azure-openai",
                  base_url="http://localhost:8787/v1",
                  azure_resource_name = "resource-gpt4-turbo-us-west",
                  azure_deploymend_id = "https://gpt4-turbo-west-us.openai.azure.com/",
                  azure_api_version = "2023-12-01-preview",
                  authorization="xxxxxxxzzzzyyyyyyyy",
                  api_key="dummy")
authorization should be "Bearer xxxxx"
are you printing the completion somewhere - wanted to check if that's causing any issues
I fixed the authorization value by adding the "Bearer " prefix. But it's still giving the same error.
I can't print the completion because this command:
Plain Text
completion = portkey.chat.completions.create(messages = [{ "role": 'user', "content": 'Say this is a test' }])

fails with the error above, so the completion variable is not initialized.
@Vrushank | Portkey thank you for the help!
This is what worked for me:
Plain Text
from openai import OpenAI

portkey = OpenAI(
    api_key="YOUR_AZURE_OPENAI_API_KEY",
    base_url="http://localhost:8787/v1",
    default_headers={
        'x-portkey-azure-resource-name': '....',
        'x-portkey-azure-deployment-id': '....',
        'x-portkey-azure-api-version': '....',
        'x-portkey-provider': 'azure-openai'
    }
)

completion = portkey.chat.completions.create(
    messages= [{ "role": 'user', "content": 'Say this is a test' }],
    model="gpt-4o"
)

print(completion.choices[0].message.content)

The model arg in the request command can get any non None value.
Add a reply
Sign up and join the conversation on Discord