Quickstart Guide

Getting Started with Hyperbolic Serverless Inference

Once we have created a Hyperbolic account, API key, and configured your billing, we can send our first inference request!

Text Generation

Llama 3.1 70B Instruct

curl -X POST "https://api.hyperbolic.xyz/v1/chat/completions" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $HYPERBOLIC_API_KEY" \
    -d '{
        "messages": [
            {
                "role": "system",
        	"content": "You are a helpful and polite assistant."
            },
            {
                "role": "user",
                "content": "What is Chinese hotpot?"
            }
        ],
        "model": "meta-llama/Meta-Llama-3.1-70B-Instruct",
        "presence_penalty": 0,
        "temperature": 0.1,
        "top_p": 0.9,
        "stream": false
    }'
import os
import openai

system_content = "You are a gourmet. Be descriptive and helpful."
user_content = "Tell me about Chinese hotpot"

client = openai.OpenAI(
    api_key="YOUR_HYPERBOLIC_API_KEY",
    base_url="https://api.hyperbolic.xyz/v1",
    )

chat_completion = client.chat.completions.create(
    model="meta-llama/Meta-Llama-3.1-70B-Instruct",
    messages=[
        {"role": "system", "content": system_content},
        {"role": "user", "content": user_content},
    ],
    temperature=0.7,
    max_tokens=1024,
)

response = chat_completion.choices[0].message.content
print("Response:\n", response)
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'YOUR_HYPERBOLIC_API_KEY',
  baseURL: 'https://api.hyperbolic.xyz/v1',
});

async function main() {
  const response = await client.chat.completions.create({
    messages: [
      {
        role: 'system',
        content: 'You are an expert travel guide.',
      },
      {
        role: 'user',
        content: 'Tell me fun things to do in San Francisco.',
      },
    ],
    model: 'meta-llama/Meta-Llama-3.1-70B-Instruct',
  });

  const output = response.choices[0].message.content;
  console.log(output);
}

main();

Image Generation

Stable Diffusion

curl -X POST "https://api.hyperbolic.xyz/v1/image/generation" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $HYPERBOLIC_API_KEY" \
    -d '{
      "model_name": "SDXL1.0-base",
      "prompt": "a photo of an astronaut riding a horse on mars",
      "height": 1024,
      "width": 1024,
      "backend": "auto"
    }' | jq -r ".images[0].image" | base64 -d > result.jpg

Audio Generation

Melo TTS

curl -X POST "https://api.hyperbolic.xyz/v1/audio/generation" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $HYPERBOLIC_API_KEY" \
    -d '{
      "text": "Hi! Welcome to Hyperbolic."
    }' | jq -r ".audio" | base64 -d > result.mp3