gateway
gateway copied to clipboard
`"Content-Length can't be present with Transfer-Encoding`
What Happened?
I'm running the gateway locally using npx @portkey-ai/gateway
and using the NodeJS SDK I got weird connection errors
const portkey = new Portkey({
apiKey: " ", // need to put something here otherwise portkey will complain
baseURL: process.env.PORTKEY_GATEWAY_URL,
Authorization: `Bearer ${process.env.OPENAI_API_KEY!}`,
provider: "openai",
});
const completion = await portkey.chat.completions.create({
messages: [{ role: "user", content: "Hello, world! 1" }],
model: "gpt-3.5-turbo",
temperature: 0,
});
The following CURL request works:
curl http://localhost:8787/v1/chat/completions -H "x-portkey-provider: openai" -H "Content-Type: application/json" -H "Authorization: ..." -d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "Hello world"
}
]
}' | jq
But in node with either fetch, node-fetch or axios I'm always getting the error "Content-Length can't be present with Transfer-Encoding"
from Portkey
axios
.post("http://localhost:8787/v1/chat/completions", data, {
headers: {
"x-portkey-provider": "openai",
"Content-Type": "application/json",
Authorization: "Bearer " + process.env.OPENAI_API_KEY!,
},
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error("Error:", error);
})
This works as expected when running using Docker
What Should Have Happened?
The Node SDK should work
Relevant Code Snippet
No response
Your Twitter/LinkedIn
https://twitter.com/da_fant