Here's a quick-start guide to help you get started with RyGen.
Get the complete list of all Models currently available on RyGen here: https://rygen.io/models
Built on OpenAI-compatible APIs, RyGen enables easy migration and integration.
# OpenAI-Compatible HTTP API: RyGen provides an OpenAI-compatible HTTP API, allowing you to integrate with existing OpenAI SDKs and tools with minimal changes.
# Chat Completions: You can send requests to our OpenAI Chat Completions-compatible endpoint using a list of conversation messages. The model processes the conversation context and returns an AI-generated response.
# Simple Messages and Prompts: Provide a list of messages representing the conversation history, and the model will generate an appropriate response based on the supplied context.
curl "https://api.rygen.io/v1/openai/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 4c31b9436d6f-f8f6-9960-0966-0e58ad84a53c" \
-d '{
"model": "moonshotai/Kimi-K2.7-Code",
"messages": [
{
"role": "user",
"content": "Hello, How Are You?"
}
]
}'# OpenAI Python Client
# RyGen is fully compatible with the official OpenAI Python client, allowing you to run inferences using familiar SDKs and workflows.
# Simply configure the client with your RyGen API key and endpoint, then use the standard OpenAI APIs to interact with RyGen models.
# Assume openai>=1.0.0
from openai import OpenAI
# Create an OpenAI client with your RyGen token and endpoint
openai = OpenAI(api_key="4c31b9436d6f-f8f6-9960-0966-0e58ad84a53c", base_url="https://api.rygen.io/v1/openai",)
chat_completion = openai.chat.completions.create(model="moonshotai/Kimi-K2.7-Code", messages=[{"role": "user", "content": "Hello, Nice to meet you!"}],)
print(chat_completion.choices[0].message.content)
print(chat_completion.usage.prompt_tokens, chat_completion.usage.completion_tokens)
# This will return something:
# Hello! It's nice to meet you too. Is there something I can help you with, or would you like to chat ?
# 12 28import OpenAI from "openai";
const openai = new OpenAI({baseURL: "https://api.rygen.io/v1/openai", apiKey: "4c31b9436d6f-f8f6-9960-0966-0e58ad84a53c",});
async function main() {
const completion = await openai.chat.completions.create({
messages: [{ role: "user", content: "Hello, Nice to meet you!" }],
model: "moonshotai/Kimi-K2.7-Code",
});
console.log(completion.choices[0].message.content);
console.log(completion.usage.prompt_tokens, completion.usage.completion_tokens);
}
main();
// This will return something:
// Hello! It's nice to meet you too. Is there something I can help you with, or would you like to chat?
// 12 26You’ll receive a response similar to the following:
{
"id": "chatcmpl-juJNxbguct",
"object": "chat.completion",
"created": 1251849261,
"model": "moonshotai/Kimi-K2.7-Code",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": " Hello! It's nice to meet you too. Is there something I can help you with or would you like to chat for a bit?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 16,
"total_tokens": 31,
"estimated_cost": 0.0000268
}
}Conversations
To create a multi-turn conversation, include the complete message history in each request. This means sending both the user's messages and the assistant's previous responses along with the latest prompt. Providing conversation history helps the model maintain context and generate more relevant, coherent responses.
You can further customize the model's behavior by including a system message that defines instructions, personality, tone, or other conversation guidelines.
curl "https://api.rygen.io/v1/openai/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 4c31b9436d6f-f8f6-9960-0966-0e58ad84a53c" \
-d '{
"model": "moonshotai/Kimi-K2.7-Code",
"messages": [
{
"role": "system",
"content": "You are a knowledgeable travel expert who gives concise and practical advice."
},
{
"role": "user",
"content": "I am planning a 5-day trip to Japan. What cities should I consider?"
},
{
"role": "assistant",
"content": "For a 5-day trip, I would recommend a combination of Tokyo, Kyoto, and Osaka. Tokyo offers modern attractions, Kyoto showcases traditional culture and temples, while Osaka is known for its food scene and vibrant nightlife."
},
{
"role": "user",
"content": "Which of these cities is best for experiencing traditional Japanese culture?"
}
]
}'# Assume openai>=1.0.0
from openai import OpenAI
# Create an OpenAI client with your RyGen token and endpoint
openai = OpenAI(
api_key="4c31b9436d6f-f8f6-9960-0966-0e58ad84a53c",
base_url="https://api.rygen.io/v1/openai",
)
chat_completion = openai.chat.completions.create(
model="moonshotai/Kimi-K2.7-Code",
messages=[
{
"role": "system",
"content": "You are a knowledgeable travel expert who provides practical and concise recommendations."
},
{
"role": "user",
"content": "I'm planning a week-long trip to Europe. Which countries would you recommend for first-time visitors?"
},
{
"role": "assistant",
"content": "For first-time visitors, France, Italy, and Spain are excellent choices. France offers iconic landmarks and culture, Italy is known for its history and cuisine, while Spain combines beautiful architecture, beaches, and vibrant nightlife."
},
{
"role": "user",
"content": "Which of these destinations would be best for someone interested in history and architecture?"
},
],
)
print(chat_completion.choices[0].message.content)
print(chat_completion.usage.prompt_tokens, chat_completion.usage.completion_tokens)
# Italy is often considered the top choice for history and architecture enthusiasts...
# 156 298import OpenAI from "openai";
const openai = new OpenAI({
baseURL: "https://api.rygen.io/v1/openai",
apiKey: "4c31b9436d6f-f8f6-9960-0966-0e58ad84a53c",
});
async function main() {
const completion = await openai.chat.completions.create({
messages: [
{
role: "system",
content: "You are a helpful fitness coach who provides clear and actionable advice."
},
{
role: "user",
content: "What are some effective exercises for improving core strength?"
},
{
role: "assistant",
content: "Some of the most effective core-strengthening exercises include planks, dead bugs, Russian twists, mountain climbers, and hanging leg raises. These exercises target multiple muscle groups and help improve stability, balance, and posture."
},
{
role: "user",
content: "Which of these exercises would be best for beginners?"
}
],
model: "moonshotai/Kimi-K2.7-Code",
});
console.log(completion.choices[0].message.content);
console.log(completion.usage.prompt_tokens, completion.usage.completion_tokens);
}
main();
// For beginners, planks and dead bugs are excellent starting points...
// 142 276The conversation above might return a response similar to the following:
{
"id": "chatcmpl-4827916350",
"object": "chat.completion",
"created": 1560823147,
"model": "moonshotai/Kimi-K2.7-Code",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "For beginners, planks and dead bugs are excellent starting points. They help build core stability, improve posture, and reduce the risk of injury while requiring little to no equipment."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 142,
"total_tokens": 418,
"completion_tokens": 276,
"estimated_cost": 0.00028741
}
}As a conversation grows, more tokens are included in each request, which can increase response times and overall processing costs. The maximum length of a conversation is constrained by the model's context window, which determines how much information the model can consider at once.
In general, larger and more capable models tend to have higher latency than smaller models, so response times may vary depending on the model you choose and the amount of context provided.
Streaming
You can enable streaming for any chat completion request by setting "stream": true When streaming is enabled, the model returns tokens incrementally as they are generated, allowing your application to display responses in real time instead of waiting for the entire completion to finish.
Streaming is especially useful for chat interfaces, interactive applications, and long-form responses where reducing perceived latency improves the user experience.
curl "https://api.rygen.io/v1/openai/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer 4c31b9436d6f-f8f6-9960-0966-0e58ad84a53c" \
-d '{
"model": "moonshotai/Kimi-K2.7-Code",
"stream": true,
"messages": [
{
"role": "user",
"content": "Write a short welcome message for a new user joining our platform."
}
]
}'from openai import OpenAI
# Create an OpenAI client with your RyGen token and endpoint
openai = OpenAI(api_key="4c31b9436d6f-f8f6-9960-0966-0e58ad84a53c", base_url="https://api.rygen.io/v1/openai",)
chat_completion = openai.chat.completions.create(
model="moonshotai/Kimi-K2.7-Code",
messages=[
{
"role": "user",
"content": "Write a short welcome message for a new user joining our platform."
}
],
stream=True,
)
for event in chat_completion:
if event.choices[0].finish_reason:
print(
event.choices[0].finish_reason,
event.usage["prompt_tokens"],
event.usage["completion_tokens"],
)
else:
print(event.choices[0].delta.content)
# Welcome
# to
# our
# platform!
# We're
# excited
# to
# have
# you
# here...
# stop 14 32import OpenAI from "openai";
const openai = new OpenAI({baseURL: "https://api.rygen.io/v1/openai", apiKey: "4c31b9436d6f-f8f6-9960-0966-0e58ad84a53c",});
async function main() {
const completion = await openai.chat.completions.create({
messages: [
{
role: "user",
content: "Write a short welcome message for a new user joining our platform."
}
],
model: "moonshotai/Kimi-K2.7-Code",
stream: true,
});
for await (const chunk of completion) {
if (chunk.choices[0].finish_reason) {
console.log(
chunk.choices[0].finish_reason,
chunk.usage.prompt_tokens,
chunk.usage.completion_tokens
);
} else {
console.log(chunk.choices[0].delta.content);
}
}
}
main();
// Welcome
// to
// our
// platform!
// We're
// excited
// to
// have
// you
// here...
// stop 14 32When streaming is enabled, the API returns a sequence of Server-Sent Events (SSE) as tokens are generated, The stream ends with a [DONE] event to signal that the response is complete.
data: {"id":"4827916350","object":"chat.completion.chunk","created":1760823147,"model":"moonshotai/Kimi-K2.7-Code","choices":[{"index":0,"delta":{"role":"assistant","content":"Welcome"},"finish_reason":null}]}
data: {"id":"4827916350","object":"chat.completion.chunk","created":1760823147,"model":"moonshotai/Kimi-K2.7-Code","choices":[{"index":0,"delta":{"content":" to"},"finish_reason":null}]}
data: {"id":"4827916350","object":"chat.completion.chunk","created":1760823147,"model":"moonshotai/Kimi-K2.7-Code","choices":[{"index":0,"delta":{"content":" RyGen"},"finish_reason":null}]}
data: {"id":"4827916350","object":"chat.completion.chunk","created":1760823147,"model":"moonshotai/Kimi-K2.7-Code","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
data: {"id":"4827916350","object":"chat.completion.chunk","created":1760823147,"model":"moonshotai/Kimi-K2.7-Code","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]
