Cerebras

Replace https://api.cerebras.ai/ with https://llmfoundry.straive.com/cerebras/.

All Cerebras models and APIs are supported, including:

  • llama3.1-70b
  • llama3.1-8b

Curl

curl -X POST https://llmfoundry.straive.com/cerebras/v1/chat/completions \
  -H "Authorization: Bearer $LLMFOUNDRY_TOKEN:my-test-project" \
  -H "Content-Type: application/json" \
  -d '{"model": "llama3-8b-8192", "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/cerebras/v1/chat/completions",
    headers={"Authorization": f"Bearer {os.environ['LLMFOUNDRY_TOKEN']}:my-test-project"},
    json={"model": "llama3.1-8b", "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/cerebras/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: "llama3-8b-8192",
    messages: [{ role: "user", content: "What is 2 + 2" }],
  }),
});
console.log(await response.json());