Welcome to Portkey Forum

Updated 2 weeks ago

Portkey in Rust

Hello everyone, i am testing Portkey atm

it looks pretty Promising

i use Rust with the async-openai crate and now i get some errors, and i dont know how to fix them

with this setup:
Plain Text
let config = OpenAIConfig::new()
    .with_api_base("https://api.portkey.ai/v1")
    .with_api_key("portkeyApiKey");

println!("using Portkey");

let openai_client = Arc::new(OpenAIClient::with_config(config));


i am getting this error:
Plain Text
ERROR async_openai::error: 71: failed deserialization of: {"status":"failure","message":"Either x-portkey-config or x-portkey-provider header is required"}


what do i need exactly?
i could create a custom http client, but what does this headers mean? cant find them in the documentation
V
N
3 comments
Hey @Newt sorry for this! Let me check this tonight and get back to you?
alright, thanks ^^ in the mean time i will try to figure it out

as long i can get it fixed in the end of the next week everything will be good, bcs then i will have the first live test with portkey ^^
it worked with a custom http client:

Plain Text
let mut headers = HeaderMap::new();
headers.insert(
    "x-portkey-virtual-key",
    "portkeyVirtualKey".parse().unwrap(),
);

let client = ReqwestClient::builder()
    .default_headers(headers)
    .build()
    .expect("valid client");
let config = OpenAIConfig::new()
    .with_api_base("https://api.portkey.ai/v1")
    .with_api_key("portkeyApiKey");

println!("using Portkey");

let openai_client = Arc::new(OpenAIClient::with_config(config).with_http_client(client));


if you want i can provide a structured example so you can add it to the documentation?
Add a reply
Sign up and join the conversation on Discord