Welcome to Portkey Forum

Updated last year

Troubleshooting string operations

Try putting "n" : "1" - 1 in strings maybe that's an issue
S
V
10 comments
I also idenfied a , missing.
Plain Text
"n": "1"
    "model": "text-davinci-003",

I fixed it, but still doesn't fix Unexpected end of JSON input
Plain Text
❯ curl --location 'http://api.portkey.ai/v1/proxy/completions' \
--header 'x-portkey-api-key: <PORTKEY_API_KEY>' \
--header 'x-portkey-mode: proxy openai' \
--header 'Authorization: Bearer <OPENAI_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
    "n": "1",
    "model": "text-davinci-003",
    "prompt": "Top 20 tallest buildings in the world"
}'
# Response
{"ok":false,"message":"Unexpected end of JSON input"}
ok i was wrong - n should be integer
and also identified the issue - the URL should be this:

https://api.portkey.ai/v1/proxy/completions

Confirmied that with these 2 changes, your code is working
This seems to work. But I guess working is limited to davinci models that's due deprecation in January. Is there a way of proxying HTTP requests for gpt-3.5-turbo models?
I tried proxy/chat/completions and passed body similar to open ai docs. It didn't work.
Can you share the code snippet?
Plain Text
curl --location --request POST 'http://api.portkey.ai/v1/proxy/chat/completions' \
--header 'x-portkey-api-key: xxxxx=' \
--header 'x-portkey-mode: proxy openai' \
--header 'Authorization: sk-xxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "gpt-3.5-turbo",
    "messages": [
        {
            "role": "system",
            "content": "You are a helpful assistant."
        },
        {
            "role": "user",
            "content": "Hello!"
        }
    ]
}'
just your earlier request with changed endpoint and messages instead of prompt should work :think:
also, this URL will also have to be https
πŸ€¦β€β™‚οΈ Now I understand. Stupid mistake. Thanks @Vrushank | Portkey
Add a reply
Sign up and join the conversation on Discord