#How do you make all the LLMs like claude/gemini and all respond in the OpenAI format as in the below

15 messages · Page 1 of 1 (latest)

merry cliff
#

from openai import OpenAI

client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key="<OPENROUTER_API_KEY>",
)

completion = client.chat.completions.create(
extra_headers={
"HTTP-Referer": "<YOUR_SITE_URL>", # Optional. Site URL for rankings on openrouter.ai.
"X-Title": "<YOUR_SITE_NAME>", # Optional. Site title for rankings on openrouter.ai.
},
model="openai/gpt-3.5-turbo",
messages=[
{
"role": "user",
"content": "What is the meaning of life?"
}
]
)
print(completion.choices[0].message.content)

OpenRouter

A unified interface for LLMs. Find the best models & prices for your prompts

hallow mural
#

+1 - I am really curious about that as well

granite coral
merry cliff
#

my question is different... I asked how they made it

granite coral
granite coral
#

I'm not sure what you're asking

merry cliff
hallow mural
#

since I am interested in this as well I was interested if they found a shortcut to do what @granite coral is saying or was this done manually for each LLM

granite coral
orchid cape
#

It can only be done manually, one has to adapt all different APIs to the same output format

merry cliff
#

I want to know how the standardize the answer from the llm

merry cliff
granite coral
hallow mural
#

thank you! please let me know if any other way or shorter thing is possible as I was trying to test one LLM to adapt to that basically