Prerequisites
Before getting started, ensure you have the following:
- An API key for your inference service
curlinstalled, or alternatively Python or Node.js if you plan to use an SDK
Step 1: Generate and export your API key
Save your API key in an environment variable rather than embedding it directly in your source code.
export INFERENCE_BASE_URL="https://api.rygen.io/v1"
export INFERENCE_API_KEY="your_api_key_here"
export INFERENCE_MODEL="minimax/minimax-m2.5"Step 2: Send your first API request
Use your API key and selected model to make your initial call to the inference service.
curl --request POST \
--url "$INFERENCE_BASE_URL/chat/completions" \
--header "Authorization: Bearer $INFERENCE_API_KEY" \
--header "Content-Type: application/json" \
--data @- <<EOF
{
"model": "${INFERENCE_MODEL}",
"messages": [
{
"role": "user",
"content": "Hello, How are you doing?"
}
],
"temperature": 0.7,
"max_tokens": 128
}
EOFA successful response usually looks like this:
{
"id": "160fc64c758b420e938644613a8d1a1c",
"object": "chat.completion",
"created": 1776012472,
"model": "minimax/minimax-m2.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I'm doing well, thank you for asking! How can I help you today?",
"reasoning_content": "The user is asking how I am. This is a casual greeting/check-in. I should respond in a friendly, conversational way.\n",
"tool_calls": null
},
"logprobs": null,
"finish_reason": "stop",
"matched_stop": 200020
}
],
"usage": {
"prompt_tokens": 42,
"total_tokens": 87,
"completion_tokens": 45,
"prompt_tokens_details": {
"cached_tokens": 41
},
"reasoning_tokens": 0
},
"metadata": {
"weight_version": "default"
}
}Python with OpenAI SDK
First, Install the SDK:
pip install openaiNext, send a request to your service using your configured API key and model:
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["INFERENCE_API_KEY"], base_url=os.environ["INFERENCE_BASE_URL"],)
response = client.chat.completions.create(
model=os.environ["INFERENCE_MODEL"],
messages=[
{"role": "user", "content": "Hello, How are you doing?"}
],
temperature=0.7,
max_tokens=128,
)
print(response.choices[0].message.content)JavaScript / TypeScript with OpenAI SDK
First, Install the SDK:
npm install openaiNext, send a request to your service using your configured API key and model:
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.INFERENCE_API_KEY,
baseURL: process.env.INFERENCE_BASE_URL,
});
const response = await client.chat.completions.create({
model: process.env.INFERENCE_MODEL,
messages: [
{
role: "user",
content: "Hello, How are you doing?",
},
],
temperature: 0.7,
max_tokens: 128,
});
console.log(response.choices[0].message.content);