Inference Quick Start
Get up and running with Hyperbolic’s Serverless Inference API in minutes. This guide walks you through making your first API calls for text, image, and audio generation.
Prerequisites
Get Your API Key
Navigate to API Keys
Click on Settings in the sidebar, then select API Keys.
Create a New Key
Click Create API Key and copy the generated key.
Keep your API key secure. Never expose it in client-side code or public repositories.
Text Generation
Generate text using large language models with the chat completions endpoint.
import requests
url = "https://api.hyperbolic.xyz/v1/chat/completions"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
data = {
"messages": [
{"role": "user", "content": "What are three tips for learning to code?"}
],
"model": "openai/gpt-oss-120b",
"max_tokens": 512,
"temperature": 0.7
}
response = requests.post(url, headers=headers, json=data)
print(response.json()["choices"][0]["message"]["content"])
curl -X POST "https://api.hyperbolic.xyz/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"messages": [
{"role": "user", "content": "What are three tips for learning to code?"}
],
"model": "openai/gpt-oss-120b",
"max_tokens": 512,
"temperature": 0.7
}'
The chat completions endpoint is OpenAI-compatible. You can use the OpenAI Python SDK by setting the base URL to https://api.hyperbolic.xyz/v1.
Image Generation
Generate images from text prompts using state-of-the-art diffusion models.
import requests
import base64
url = "https://api.hyperbolic.xyz/v1/image/generation"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
data = {
"model_name": "FLUX.1-dev",
"prompt": "A futuristic city skyline at sunset, cyberpunk style",
"steps": 30,
"cfg_scale": 5,
"height": 1024,
"width": 1024
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
# Save the generated image
image_data = base64.b64decode(result["images"][0]["image"])
with open("generated_image.png", "wb") as f:
f.write(image_data)
curl -X POST "https://api.hyperbolic.xyz/v1/image/generation" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model_name": "FLUX.1-dev",
"prompt": "A futuristic city skyline at sunset, cyberpunk style",
"steps": 30,
"cfg_scale": 5,
"height": 1024,
"width": 1024
}'
The response contains a base64-encoded image in the images array. Decode it to save or display the generated image.
Audio Generation
Convert text to natural-sounding speech using the audio generation endpoint.
import requests
import base64
url = "https://api.hyperbolic.xyz/v1/audio/generation"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
data = {
"text": "Welcome to Hyperbolic! This is an example of text-to-speech generation.",
"speed": 1
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
# Save the generated audio
audio_data = base64.b64decode(result["audio"])
with open("generated_audio.mp3", "wb") as f:
f.write(audio_data)
curl -X POST "https://api.hyperbolic.xyz/v1/audio/generation" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"text": "Welcome to Hyperbolic! This is an example of text-to-speech generation.",
"speed": 1
}'
The speed parameter controls playback speed (1.0 is normal). The response contains base64-encoded audio data.
Next Steps