Skip to main content
LocoPal AiLocoPal Ai
Quick Start

Guide

Common Tool Integration

Configuration for the OpenAI SDK, Cherry Studio, OpenCode, Trae, and other compatible clients

View Markdown

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 itemValue
Base URLhttps://locopalai.com/v1
API keyThe sk-... created in the console
Model IDThe 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 openai
import 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 openai
import 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

  1. Open the model service settings and add an OpenAI-compatible service.
  2. For the API address, enter https://locopalai.com/v1.
  3. For the API key, enter the key created in the console.
  4. Click to fetch models, or manually enter a model ID returned by /v1/models.
  5. 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:

  1. When "Full URL" is off, enter https://locopalai.com/v1.
  2. When "Full URL" is on, enter https://locopalai.com/v1/chat/completions.
  3. Enter the API key.
  4. Enter a currently available model ID.
  5. 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/json

For 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

  1. GET /v1/models returns at least one model.
  2. A text call returns choices.
  3. Video creation returns a task ID.
  4. Video queries return a status and do not create duplicates.
  5. When the current group provides a text-to-speech model, POST /v1/audio/speech returns playable binary audio.
  6. On 401, check the key; on 429, wait as instructed; on 5xx, save the RequestId and then decide whether it can be retried.
Was this page helpful?

On this page