openrouter_client = OpenAI(
api_key=st.secrets["OPENROUTER_API_KEY"],
base_url="https://openrouter.ai/api/v1")
response = openrouter_client.chat.completions.create(
model=model.name,
messages=messages,
)
this appears in my logs:
13:07:45 - HTTP Response: POST https://openrouter.ai/api/v1/chat/completions "200 OK" Headers({'date': 'Tue, 18 Feb 2025 13:07:22 GMT', 'content-type': 'application/json', 'transfer-encoding': 'chunked', 'connection': 'keep-alive', 'access-control-allow-origin': '*', 'x-clerk-auth-message': 'Invalid JWT form. A JWT consists of three parts separated by dots. (reason=token-invalid, token-carrier=header)', 'x-clerk-auth-reason': 'token-invalid', 'x-clerk-auth-status': 'signed-out', 'vary': 'Accept-Encoding', 'server': 'cloudflare', 'cf-ray': '913e3d609bff79b0-LHR', 'content-encoding': 'br'})
13:07:45 - ChatCompletion(id='gen-1739884042-c3CQwXUlPCZzo85JmV03', choices=[Choice(finish_reason=None, index=0, logprobs=None, message=ChatCompletionMessage(content='', refusal=None, role='assistant', audio=None, function_call=None, tool_calls=None))], created=1739884042, model='meta-llama/llama-3.3-70b-instruct', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=0, prompt_tokens=43, total_tokens=43, completion_tokens_details=None, prompt_tokens_details=None), provider='Chutes')
It returns a 200 OK message with no content every time, supposeddly because of JWT errors. But it's not supposed to be using JWT at all is it? OpenRouter's keys aren't in JWT format.
I can curl fine with the same key. Just the OpenAI Python client doesn't work.