Welcome to Portkey Forum

Updated 5 months ago

portkey from go

I'd suggest to use some method in Go to directly make REST calls. Not sure how good the unofficial Go OpenAI SDK is.
b
V
8 comments
hey @Vrushank | Portkey, was giving a shot to the unofficial sdk. I am just wondering how i can pass some headers to use a certain prompt id and variables?
i was able to set other things like the base url, conifg, metadata, and api key headers
Plain Text
    headers := map[string]string{
        "x-portkey-config":   "--",
        "x-portkey-metadata": "{\"foo\":\"bar\"}",
        "x-portkey-api-key":  "--",
    }

    client := openai.NewClientWithConfig(openai.ClientConfig{ //nolint: exhaustruct
        BaseURL: "https://api.portkey.ai/v1",
        HTTPClient: &http.Client{ //nolint: exhaustruct
            Transport: &transportWithCustomHeaders{
                headers: headers,
            },
        },
    })
this is what I am doing at the moment ^
Hmm, looking at the docs that might not be possible with prompt templates
unless i render them first
Yep! That's the only way right now for prompts specifically. Wrote about how you can do it in Python/TS here - https://portkey.ai/docs/product/prompt-library/retrieve-prompt-templates#using-the-render-output-in-a-new-request
Add a reply
Sign up and join the conversation on Discord