Guide
Common Tool Integration
Configuration for the OpenAI SDK, Cherry Studio, OpenCode, Trae, and other compatible clients
Common Tool Integration
Clients that support a custom OpenAI-compatible address usually only need a Base URL, an API key, and a model ID. The model catalog is based on the real-time result of /v1/models.
OpenAI-compatible clients cover the model catalog, text chat, image generation, video tasks, and text-to-speech APIs; the asset library APIs use the platform's own /api/v1/materials/... paths, so please send HTTP requests directly as described in Asset Library API Overview; clients are not responsible for this part.
General configuration
| Configuration item | Value |
|---|---|
| Base URL | https://locopalai.com/v1 |
| API key | The sk-... created in the console |
| Model ID | The data[].id returned by /v1/models |
| Chat path | /chat/completions |
| Models path | /models |
If the tool asks for a full URL, use https://locopalai.com/v1/chat/completions; if it asks for a Base URL, fill in up to /v1.
The platform may also show addresses such as https://us-api.locopalai.com for overseas models or specific network environments. Use the address currently shown in the console when integrating; do not put both domains into the same client configuration.
OpenAI JavaScript SDK
npm install openaiimport OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.LOCOPAL_API_KEY,
baseURL: 'https://locopalai.com/v1',
})
const models = await client.models.list()
const result = await client.chat.completions.create({
model: models.data[0].id,
messages: [{ role: 'user', content: '你好' }],
})
console.log(result.choices[0].message.content)OpenAI Python SDK
pip install openaiimport os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["LOCOPAL_API_KEY"],
base_url="https://locopalai.com/v1",
)
models = client.models.list()
response = client.chat.completions.create(
model=models.data[0].id,
messages=[{"role": "user", "content": "你好"}],
)
print(response.choices[0].message.content)Cherry Studio
- Open the model service settings and add an OpenAI-compatible service.
- For the API address, enter
https://locopalai.com/v1. - For the API key, enter the key created in the console.
- Click to fetch models, or manually enter a model ID returned by
/v1/models. - After saving, start a new conversation to verify.
If the model list is empty, first use curl to verify /v1/models with the same key; if curl works, check whether the client is appending /v1 twice.
OpenCode
Configure an OpenAI-compatible Provider in opencode.json at the user or project level:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"locopal": {
"npm": "@ai-sdk/openai-compatible",
"name": "LocoPal Ai",
"options": {
"baseURL": "https://locopalai.com/v1",
"apiKey": "{env:LOCOPAL_API_KEY}"
},
"models": {
"你的模型ID": { "name": "你的模型ID" }
}
}
},
"model": "locopal/你的模型ID"
}The configuration syntax may change with client versions; follow the current client's configuration specification. The key point is that the Base URL, API key, and model ID are consistent.
Trae and other IDEs
In "Settings → Models → Add Model", choose the OpenAI-compatible format:
- When "Full URL" is off, enter
https://locopalai.com/v1. - When "Full URL" is on, enter
https://locopalai.com/v1/chat/completions. - Enter the API key.
- Enter a currently available model ID.
- Enable vision or tool calling options according to the model's real capabilities.
Postman / Apifox
Create three environment variables: base_url=https://locopalai.com, api_key=你的APIKey, and model=从 /v1/models 获取的模型 ID. Add the following to each request:
Authorization: Bearer {{api_key}}
Content-Type: application/jsonFor video tasks, first save the ID from the create response, then use GET to query {{base_url}}/v1/video/generations/{{task_id}}.
Server-side proxy recommendation
Browsers and mobile apps should not hold the platform API key directly. The recommended architecture is "web page or app → your business backend → LocoPal Ai". The business backend handles user authentication, parameter validation, request logging, task ID persistence, quota control, and result storage.
Integration self-check
GET /v1/modelsreturns at least one model.- A text call returns
choices. - Video creation returns a task ID.
- Video queries return a status and do not create duplicates.
- When the current group provides a text-to-speech model,
POST /v1/audio/speechreturns playable binary audio. - On
401, check the key; on429, wait as instructed; on5xx, save the RequestId and then decide whether it can be retried.
