Getting Started

Sign in, create an API key, test a model, and review usage for Oimi API.

Getting Started

This guide walks you through the basic Oimi API integration flow. After completing it, you can create an API key, choose an available model, test a request in Experience Center, and call the API from your application.

1. Sign In to the Console

Open the platform home page and sign in or create an account. After your account is ready, open the console overview.

The console overview shows credit balance, request count, usage summary, quickstart example, API access information, and recent calls. Use it to confirm your service URL, account status, and recent request activity.

2. Create an API Key

Open Console / API Keys, then click Create API key.

You only need to enter a note when creating a key. Use a note that identifies the key purpose, such as Production app, Staging, or a project name.

Copy the full key immediately after it is created. The full key will not be shown again after you close the dialog.

In API Keys, you can manage existing keys:

  • Enable or disable a key
  • Delete a key you no longer use
  • Adjust key quota
  • Change model variant
  • Review note, status, and usage information

3. Choose a Model

Open Models to view the models available to your account. The list shows model ID, input price, output price, cache read/write price, model variant, and multiplier.

When integrating your app, use a model ID exactly as shown in Models. Different accounts or model variants may have different available models.

4. Test in Experience Center

Open Experience Center, choose a model and an API key, then send a test request.

Experience Center is useful before production integration because it verifies model behavior, parameters, and key permission. You can:

  • Choose a model
  • Choose an API key
  • Configure system/user/assistant messages
  • Adjust temperature, top_p, max_tokens, and other parameters
  • Enable or disable streaming output
  • Review response content and errors

5. Integrate Your Application

If your application already uses the OpenAI SDK, you usually only need to replace base_url and api_key.

import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: process.env.OIMI_API_KEY,
  baseURL: 'https://api.oimi.xin/v1'
})

const completion = await client.chat.completions.create({
  model: 'model-id',
  messages: [{ role: 'user', content: 'Write a launch checklist' }]
})

console.log(completion.choices[0].message.content)

Replace model-id with an actual model ID from Models. Keep API keys in server-side environment variables. Do not put them in browser code or public repositories.

6. Common Client Integrations

Before configuring Codex, Claude Code, OpenCode, Gemini, or CC-Switch, prepare these values:

  • Service URL: https://api.oimi.xin
  • OpenAI-compatible service URL: https://api.oimi.xin/v1
  • API key: create it in API Keys, then copy and store it immediately
  • Model ID: copy an available model ID from Models
  • Verification entry: test the same API key and model in Experience Center first

The examples below use model-id as a placeholder. Replace it with an actual model ID shown in Models.

Codex

Codex is useful for coding tasks in the terminal or Codex desktop app. To use Oimi API, add a custom model provider to Codex.

Use the user-level config file so the same Oimi API settings are available across projects:

  • Windows: C:\Users\<User>\.codex\config.toml
  • macOS / Linux: ~/.codex/config.toml

Add this provider:

model = "model-id"
model_provider = "oimi"

[model_providers.oimi]
name = "Oimi API"
base_url = "https://api.oimi.xin/v1"
env_key = "OIMI_API_KEY"
wire_api = "chat"

Then set the API key in your terminal.

Windows PowerShell:

$env:OIMI_API_KEY="your Oimi API key"
codex

macOS / Linux:

export OIMI_API_KEY="your Oimi API key"
codex

To temporarily choose a model when starting Codex, pass the model ID:

codex -m model-id

If you are not sure which wire protocol to use, start with wire_api = "chat". Change it to wire_api = "responses" only when the selected model and client setup require the Responses protocol.

Claude Code

Claude Code uses the Anthropic Messages protocol. Oimi API's Claude-compatible endpoint is https://api.oimi.xin/v1/messages, but Claude Code usually expects the base service URL https://api.oimi.xin because the client appends the protocol path.

Windows PowerShell:

$env:ANTHROPIC_BASE_URL="https://api.oimi.xin"
$env:ANTHROPIC_AUTH_TOKEN="your Oimi API key"
$env:ANTHROPIC_MODEL="model-id"
claude

macOS / Linux:

export ANTHROPIC_BASE_URL="https://api.oimi.xin"
export ANTHROPIC_AUTH_TOKEN="your Oimi API key"
export ANTHROPIC_MODEL="model-id"
claude

If you also want small tasks to use the same model, set:

export ANTHROPIC_SMALL_FAST_MODEL="model-id"

Note: if a tool asks for the base URL, use https://api.oimi.xin. Use https://api.oimi.xin/v1/messages only when the tool explicitly asks for the full endpoint URL.

OpenCode

OpenCode can connect to Oimi API through a custom OpenAI-compatible provider. This is useful if you already use OpenCode in the terminal.

Common config locations:

  • Windows: %APPDATA%\opencode\opencode.jsonc
  • macOS / Linux: ~/.config/opencode/opencode.jsonc

If your OpenCode version shows a config directory command or settings UI, prefer the path shown by your installed version.

Add an Oimi API provider:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "oimi": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Oimi API",
      "options": {
        "baseURL": "https://api.oimi.xin/v1",
        "apiKey": "{env:OIMI_API_KEY}"
      },
      "models": {
        "model-id": {
          "name": "model-id"
        }
      }
    }
  }
}

Then set the environment variable and start OpenCode.

Windows PowerShell:

$env:OIMI_API_KEY="your Oimi API key"
opencode

macOS / Linux:

export OIMI_API_KEY="your Oimi API key"
opencode

Inside OpenCode, select the oimi provider and the model-id model. If your version uses commands such as /connect or /models, follow the prompts for a custom provider and enter the same service URL, API key, and model ID.

Gemini

Oimi API supports the Gemini-compatible protocol. The endpoint shape is:

https://api.oimi.xin/v1beta/models/model-id:generateContent

Authentication can use the x-goog-api-key header or the ?key= query parameter.

If your Gemini client supports a custom service URL, fill in:

  • Service URL: https://api.oimi.xin
  • API key: your Oimi API key
  • Model ID: copy it from Models
  • Endpoint path: /v1beta/models/model-id:generateContent

You can verify the Gemini-compatible endpoint with curl first.

Windows PowerShell:

$env:OIMI_API_KEY="your Oimi API key"
curl "https://api.oimi.xin/v1beta/models/model-id:generateContent?key=$env:OIMI_API_KEY" `
  -H "Content-Type: application/json" `
  -d "{\"contents\":[{\"parts\":[{\"text\":\"Introduce Oimi API in one sentence\"}]}]}"

macOS / Linux:

export OIMI_API_KEY="your Oimi API key"
curl "https://api.oimi.xin/v1beta/models/model-id:generateContent?key=$OIMI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"parts":[{"text":"Introduce Oimi API in one sentence"}]}]}'

Some Gemini CLI versions only support Google's official Gemini endpoint and do not expose a custom service URL option. If your client has no custom service URL setting, use CC-Switch or another adapter/client that can route Gemini-compatible requests to Oimi API.

CC-Switch

CC-Switch is useful when you need to switch Claude Code, Codex, OpenCode, Gemini, or other clients between different service providers. It usually stores service URL, API key, and model settings in a UI, then applies them to the selected client.

When adding Oimi API as a provider in CC-Switch, use:

  • Name: Oimi API
  • Service URL: https://api.oimi.xin
  • OpenAI-compatible service URL: https://api.oimi.xin/v1
  • API key: your Oimi API key
  • Model: model-id

If CC-Switch asks you to choose a protocol:

  • Claude Code: choose Anthropic / Claude compatible, and use https://api.oimi.xin as the base URL
  • Codex / OpenCode: choose OpenAI compatible, and use https://api.oimi.xin/v1
  • Gemini: choose Gemini compatible, and use https://api.oimi.xin as the base URL

If the UI asks for a full endpoint URL instead of a base URL:

  • Claude Messages: https://api.oimi.xin/v1/messages
  • OpenAI Chat Completions: https://api.oimi.xin/v1/chat/completions
  • Gemini generateContent: https://api.oimi.xin/v1beta/models/model-id:generateContent

After saving, switch the current provider to Oimi API and test in the target client. It is best to confirm the same API key and model in Experience Center first, then troubleshoot client configuration.

How to Verify After Integration

Use this order when troubleshooting:

  • Test the same API key and model in Experience Center
  • Send one minimal request with curl or an SDK
  • Test in Codex, Claude Code, OpenCode, Gemini, or CC-Switch
  • If it fails, open Usage and check whether a request record was created
  • If there is no request record, check the service URL, header, and API key
  • If there is a request record, check the error message, model ID, quota, and model variant

7. Review Usage and Costs

Open Usage to filter call records by time, model, API key, group, request ID, or upstream request ID.

Usage records can show:

  • Credit cost
  • RPM / TPM
  • Model name
  • API key name
  • Request time
  • Billing details
  • Latency and response information

Open Costs to view credit balance, recharge entry, and billing records. If a request fails because of insufficient quota, check account balance first, then check the quota settings of the API key.