OpenRouter
Replace https://openrouter.ai/api/
with https://llmfoundry.straive.com/openrouter/
.
All OpenRouter models and APIs are supported, including:
meta-llama/llama-3.2-11b-vision-instruct
mistralai/pixtral-12b
qwen/qwen-2-vl-72b-instruct
nousresearch/hermes-3-llama-3.1-405b
microsoft/phi-3.5-mini-128k-instruct
Curl
curl -X POST https://llmfoundry.straive.com/openrouter/v1/chat/completions \
-H "Authorization: Bearer $LLMFOUNDRY_TOKEN:my-test-project" \
-H "Content-Type: application/json" \
-d '{"model": "meta-llama/llama-3.2-11b-vision-instruct", "messages": [{"role": "user", "content": "What is 2 + 2"}]}'
Python requests
import os
import requests # Or replace requests with httpx
response = requests.post(
"https://llmfoundry.straive.com/openrouter/v1/chat/completions",
headers={"Authorization": f"Bearer {os.environ['LLMFOUNDRY_TOKEN']}:my-test-project"},
json={"model": "meta-llama/llama-3.2-11b-vision-instruct", "messages": [{"role": "user", "content": "What is 2 + 2"}]}
)
print(response.json())
JavaScript
const token = process.env.LLMFOUNDRY_TOKEN;
const response = await fetch("https://llmfoundry.straive.com/openrouter/v1/chat/completions", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}:my-test-project` },
// If the user is already logged into LLM Foundry, use `credentials: "include"` to send **THEIR** API token instead of the `Authorization` header.
credentials: "include",
body: JSON.stringify({
model: "meta-llama/llama-3.2-11b-vision-instruct",
messages: [{ role: "user", content: "What is 2 + 2" }],
}),
});
console.log(await response.json());
Python OpenAI
import os
from openai import OpenAI
client = OpenAI(
api_key=f'{os.environ.get("LLMFOUNDRY_TOKEN")}:my-test-project',
base_url="https://llmfoundry.straive.com/openrouter/v1",
)
# Rest of your code is the same
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": "What is 2 + 2?"}],
model="meta-llama/llama-3.2-11b-vision-instruct",
)
print(chat_completion.json())
LangChain
import os
from langchain_openai import ChatOpenAI
chat_model = ChatOpenAI(
openai_api_base="https://llmfoundry.straive.com/openrouter/v1",
openai_api_key=f'{os.environ["LLMFOUNDRY_TOKEN"]}:my-test-project',
model="meta-llama/llama-3.2-11b-vision-instruct"
)
print(chat_model.invoke("What is 2 + 2?").content)