BytePlus

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.

Getting started

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.

Tracking BytePlus API calls

1from opik.integrations.openai import track_openai
2from openai import OpenAI
3
4# Initialize the OpenAI client with BytePlus base URL
5client = OpenAI(
6 base_url="https://ark.ap-southeast.bytepluses.com/api/v3",
7 api_key="YOUR_BYTEPLUS_API_KEY"
8)
9client = track_openai(client)
10
11response = client.chat.completions.create(
12 model="kimi-k2-250711", # You can use any model available on BytePlus
13 messages=[
14 {"role": "user", "content": "Hello, world!"}
15 ],
16 temperature=0.7,
17 max_tokens=100
18)
19
20print(response.choices[0].message.content)

Advanced Usage

Using with @track decorator

You can combine the tracked client with Opik’s @track decorator for comprehensive tracing:

1from opik import track
2from opik.integrations.openai import track_openai
3from openai import OpenAI
4
5client = OpenAI(
6 base_url="https://ark.ap-southeast.bytepluses.com/api/v3",
7 api_key="YOUR_BYTEPLUS_API_KEY"
8)
9client = track_openai(client)
10
11@track
12def analyze_data_with_ai(query: str):
13 """Analyze data using BytePlus AI models."""
14
15 response = client.chat.completions.create(
16 model="kimi-k2-250711",
17 messages=[
18 {"role": "user", "content": query}
19 ]
20 )
21
22 return response.choices[0].message.content
23
24# Call the tracked function
25result = analyze_data_with_ai("Analyze this business data...")

Troubleshooting

Common Issues

  1. Authentication Errors: Ensure your API key is correct and has the necessary permissions
  2. Model Not Found: Verify the model name is available on BytePlus
  3. Rate Limiting: BytePlus may have rate limits; implement appropriate retry logic
  4. Base URL Issues: Ensure the base URL is correct for your BytePlus deployment

Getting Help

Next Steps

Once you have BytePlus integrated with Opik, you can:

For more information about using Opik with OpenAI-compatible APIs, see the OpenAI integration guide.