apps/opik-documentation/documentation/fern/docs/tracing/integrations/byteplus.mdx
BytePlus is ByteDance's AI-native enterprise platform offering ModelArk, a comprehensive Platform-as-a-Service (PaaS) solution for deploying and utilizing powerful large language models. It provides access to SkyLark models, DeepSeek V3.1, Kimi-K2, and other cutting-edge AI models with enterprise-grade security and scalability.
This guide explains how to integrate Opik with BytePlus using the OpenAI SDK. BytePlus provides OpenAI-compatible API endpoints that allow you to use the standard OpenAI client with BytePlus models.
First, ensure you have both opik and openai packages installed:
pip install opik openai
You'll also need a BytePlus API key. Find a guide on creating your BytePlus API keys for model services here.
from opik.integrations.openai import track_openai
from openai import OpenAI
# Initialize the OpenAI client with BytePlus base URL
client = OpenAI(
base_url="https://ark.ap-southeast.bytepluses.com/api/v3",
api_key="YOUR_BYTEPLUS_API_KEY"
)
client = track_openai(client)
response = client.chat.completions.create(
model="kimi-k2-250711", # You can use any model available on BytePlus
messages=[
{"role": "user", "content": "Hello, world!"}
],
temperature=0.7,
max_tokens=100
)
print(response.choices[0].message.content)
You can combine the tracked client with Opik's @track decorator for comprehensive tracing:
from opik import track
from opik.integrations.openai import track_openai
from openai import OpenAI
client = OpenAI(
base_url="https://ark.ap-southeast.bytepluses.com/api/v3",
api_key="YOUR_BYTEPLUS_API_KEY"
)
client = track_openai(client)
@track
def analyze_data_with_ai(query: str):
"""Analyze data using BytePlus AI models."""
response = client.chat.completions.create(
model="kimi-k2-250711",
messages=[
{"role": "user", "content": query}
]
)
return response.choices[0].message.content
# Call the tracked function
result = analyze_data_with_ai("Analyze this business data...")
Once you have BytePlus integrated with Opik, you can:
For more information about using Opik with OpenAI-compatible APIs, see the OpenAI integration guide.