# Flex247 Documentation — Complete AI Corpus

> Canonical machine-readable export of the public Flex247 documentation. No authentication or JavaScript is required.

Index: https://ai-apidocs.noflex.work/llms.txt
Human docs: https://ai-apidocs.noflex.work/
API base URL: https://api.noflex.work/v1

# Language: English (en)

---

## Document: Anthropic Protocol

Source: https://ai-apidocs.noflex.work/en/anthropic-compatible

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/anthropic-compatible](https://ai-apidocs.noflex.work/en/anthropic-compatible)

# Anthropic Protocol

Use this protocol with Claude Code, Anthropic SDKs and Messages API clients.

<div class="api-endpoint"><strong>Base URL</strong><code>https://api.noflex.work</code></div>

## cURL

```bash
curl https://api.noflex.work/v1/messages \
  -H "x-api-key: sk-your-flex247-key" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "your-claude-model-id",
    "max_tokens": 512,
    "messages": [{"role": "user", "content": "Return only OK"}]
  }'
```

## JavaScript / TypeScript

```bash
npm install @anthropic-ai/sdk
```

```js
import Anthropic from '@anthropic-ai/sdk'

const client = new Anthropic({
  apiKey: process.env.FLEX247_API_KEY,
  baseURL: 'https://api.noflex.work'
})

const message = await client.messages.create({
  model: 'your-claude-model-id',
  max_tokens: 512,
  messages: [{ role: 'user', content: 'Review this API design.' }]
})

console.log(message.content[0].text)
```

## Python

```bash
pip install anthropic
```

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["FLEX247_API_KEY"],
    base_url="https://api.noflex.work",
)

message = client.messages.create(
    model="your-claude-model-id",
    max_tokens=512,
    messages=[{"role": "user", "content": "Summarize this change."}],
)

print(message.content[0].text)
```

## Common configuration mistakes

- Avoid a duplicated `/v1/v1` in `ANTHROPIC_BASE_URL`.
- Use the complete model ID shown in Flex247 Model Square.
- Remove whitespace around `x-api-key` or `ANTHROPIC_AUTH_TOKEN`.
- If the client supports only OpenAI-style requests, use [OpenAI Compatible](./openai-compatible).


---

## Document: Text & Code Requests

Source: https://ai-apidocs.noflex.work/en/api-examples

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/api-examples](https://ai-apidocs.noflex.work/en/api-examples)

# Text & Code Requests

These examples use the Flex247 OpenAI Compatible endpoint.

## Basic chat

```bash
curl https://api.noflex.work/v1/chat/completions \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [{"role":"user","content":"Write one product tagline."}]
  }'
```

## System instructions

```json
{
  "model": "your-model-id",
  "messages": [
    {"role": "system", "content": "Act as a senior code reviewer. State risks first, then propose the smallest safe change."},
    {"role": "user", "content": "Review the following function."}
  ]
}
```

## Multi-turn chat

Include the history you want the model to retain:

```js
const messages = [
  { role: 'user', content: 'Suggest three project names.' },
  { role: 'assistant', content: 'Nova, Orbit, Canvas' },
  { role: 'user', content: 'Choose the second and write a tagline.' }
]

const result = await client.chat.completions.create({
  model: 'your-model-id',
  messages
})
```

## JSON output

For models supporting structured output, request JSON and still validate the schema in production:

```json
{
  "model": "your-model-id",
  "messages": [
    {"role":"user","content":"Return JSON with title, summary and tags."}
  ],
  "response_format": {"type":"json_object"}
}
```

## Timeouts and retries

- Retry timeouts, interrupted connections and selected `5xx` errors only a limited number of times.
- Do not repeatedly retry `401`; verify the key first.
- Use exponential backoff for `429` and reduce concurrency.
- Stream long tasks when supported.


---

## Document: Account & API Keys

Source: https://ai-apidocs.noflex.work/en/api-keys

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/api-keys](https://ai-apidocs.noflex.work/en/api-keys)

# Account & API Keys

An API key represents access to your account. Give each application its own key to make usage tracking, rotation and incident response easier.

## Create a key

1. [Sign in to Flex247](https://noflex.work/sign-in).
2. Open **API Keys**.
3. Choose a descriptive name such as `MacBook-Codex` or `Production-Store`.
4. Set the group, model restrictions and quota when required.
5. Create the key and store the complete value immediately.

## Authentication headers

OpenAI Compatible requests use a Bearer token:

```http
Authorization: Bearer sk-your-flex247-key
```

Anthropic Protocol requests can use:

```http
x-api-key: sk-your-flex247-key
```

## Recommended practices

- Use different keys for development, staging and production.
- Never embed keys in browser code, mobile apps or public repositories.
- Load keys through environment variables or a server-side secret manager.
- Disable a suspicious key before creating its replacement.
- Review **Usage Logs** to verify models, token usage and charges.

## Rotate a key without downtime

1. Create a replacement key.
2. Update the application.
3. Send a test request and check its usage log.
4. Disable the old key only after its traffic has stopped.

## Teams and devices

Avoid sharing one key across people or services. Per-user and per-service keys make ownership and troubleshooting clear.


---

## Document: IDEs & Chat Clients

Source: https://ai-apidocs.noflex.work/en/apps-and-ides

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/apps-and-ides](https://ai-apidocs.noflex.work/en/apps-and-ides)

# IDEs & Chat Clients

Most clients that support custom providers can connect with the same Flex247 parameters.

## Generic OpenAI Compatible template

| Field | Value |
| --- | --- |
| Provider / Type | OpenAI Compatible / Custom OpenAI |
| API Key | `sk-your-flex247-key` |
| Base URL | `https://api.noflex.work/v1` |
| Model | Exact model ID from Model Square |

This pattern works with OpenAI-style custom providers in clients such as Cline, Roo Code, Kilo Code and Cherry Studio.

## Generic Anthropic template

| Field | Value |
| --- | --- |
| Provider / Type | Anthropic / Custom Anthropic |
| API Key | `sk-your-flex247-key` |
| Base URL | `https://api.noflex.work` |
| Model | Anthropic-compatible model ID |

## Setup flow

1. Open the client’s Provider, Models or API settings.
2. Choose a custom provider.
3. Enter the Base URL required by the protocol.
4. Paste the Flex247 API key.
5. Enter the model ID or refresh the model list.
6. Save and send a short test message.

## Common causes of failure

- `/v1` is missing or duplicated.
- The model ID differs from Model Square.
- The key group does not have a route for that model.
- The client is locked to one protocol but the other provider type was selected.
- The client cached the old configuration and needs a full restart.


---

## Document: Connect CC Switch to Flex AI

Source: https://ai-apidocs.noflex.work/en/cc-switch

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/cc-switch](https://ai-apidocs.noflex.work/en/cc-switch)

# Connect CC Switch to Flex AI

CC Switch is a third-party cross-platform desktop tool for managing providers across Claude Code, Codex, OpenCode and other apps. Its local routing service can also record requests, track usage and apply failover.

- [Only official website](https://ccswitch.io)
- [Official GitHub repository](https://github.com/farion1231/cc-switch)
- [Official downloads](https://github.com/farion1231/cc-switch/releases)

::: warning Download only from official sources
The CC Switch documentation recommends using only `ccswitch.io`, GitHub Releases or the source repository. Never give an API key or login credential to an unofficial installer.
:::

## 1. Install

- Windows: download `Windows.msi`, or use the `Windows-Portable.zip` build.
- macOS: download the `.dmg`, or run `brew install --cask cc-switch`.
- Linux: select the `.deb`, `.rpm` or `.AppImage` package.

Make sure Codex is installed and has been started at least once.

## 2. Add the Flex247 provider

1. Select **Codex** at the top of CC Switch.
2. Click **+** in the upper-right corner.
3. Choose **App-specific provider**, then **Custom**.
4. Enter these values.

| Field | Value |
| --- | --- |
| Name | `Flex247` |
| API Endpoint / Base URL | `https://api.noflex.work/v1` |
| API Key | Your dedicated Flex247 key |
| Wire API / API format | **Responses** |
| Model | An exact Responses-compatible model ID from Model Square |
| Local route mapping required | Off; enable it only for a Chat Completions-only upstream |

After entering the key and endpoint, click **Get Models** beside the model field. CC Switch calls `/v1/models` and lets you choose a model directly.

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cc-switch-codex-provider.png" alt="Official CC Switch add Codex provider interface">
  <figcaption>Figure 1: Official CC Switch Codex-provider form example. The name, endpoint and models shown in this Chinese-language screenshot are sample values; replace them with the Flex247 values in the table above. Image from the <a href="https://github.com/farion1231/cc-switch/blob/main/docs/images/codex-deepseek-routing/02-deepseek-codex-routing-form.png">project repository</a>.</figcaption>
</figure>

Start with `gpt-5.6-luna`, or select another Responses-compatible model from [Model Square](https://noflex.work/pricing).

## 3. Save and switch

1. Save the provider.
2. Select `Flex247` on the main screen and click **Enable**.
3. Restart Codex or open a new terminal.
4. Send a read-only test request and confirm it in Flex247 **Usage Logs**.

If the custom screen asks for raw Codex configuration, use the following core values. Keep the API key in the CC Switch credential field rather than a public file.

```toml
model = "gpt-5.6-luna"
model_provider = "flex247"

[model_providers.flex247]
name = "Flex247"
base_url = "https://api.noflex.work/v1"
wire_api = "responses"
requires_openai_auth = true
```

## 4. Optional: enable local routing

For request logs, usage statistics or failover:

1. Open **Settings → Advanced → Routing Service**.
2. Start the routing service.
3. Enable **Codex Routing** under **App Routing**.

Codex then connects to the CC Switch local endpoint, normally `http://127.0.0.1:15721/v1`, and CC Switch forwards requests to Flex247. Do not use this local URL as the upstream Base URL of the Flex247 provider.

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cc-switch-local-routing.png" alt="Official CC Switch Codex local routing interface">
  <figcaption>Figure 2: Codex local-routing interface from the official CC Switch documentation. After enabling it, use the local address shown by the app. Image from the <a href="https://github.com/farion1231/cc-switch/blob/main/docs/images/codex-deepseek-routing/03-local-route-codex-takeover.png">project repository</a>.</figcaption>
</figure>

## Chat Completions models

For a model that supports only `/v1/chat/completions`:

1. Change the provider protocol to **Chat Completions**.
2. Enable **Local route mapping required**.
3. Configure the Codex model mapping and keep the routing service running.

Codex natively uses the Responses API, so a Chat Completions-only model requires local protocol conversion.

## Troubleshooting

### The model list does not load

Check the API key, Base URL and account balance. The Base URL must be `https://api.noflex.work/v1`.

### The switch does not take effect

Restart Codex and the terminal. Confirm that the active CC Switch app panel is **Codex**, not Claude Code or another app.

### Local routing is not running

Start the service in Advanced settings before enabling Codex routing, and check that port `15721` is free.

## Official references

- [Installation guide](https://github.com/farion1231/cc-switch/blob/main/docs/user-manual/en/1-getting-started/1.2-installation.md)
- [Add a provider](https://github.com/farion1231/cc-switch/blob/main/docs/user-manual/en/2-providers/2.1-add.md)
- [App routing](https://github.com/farion1231/cc-switch/blob/main/docs/user-manual/en/4-proxy/4.2-routing.md)


---

## Document: Claude Code

Source: https://ai-apidocs.noflex.work/en/claude-code

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/claude-code](https://ai-apidocs.noflex.work/en/claude-code)

# Claude Code

Connect Claude Code to Flex247 through its Anthropic-compatible environment variables.

## 1. Install

### Windows PowerShell

```powershell
irm https://claude.ai/install.ps1 | iex
```

### macOS / Linux

```bash
curl -fsSL https://claude.ai/install.sh | bash
```

Verify the installation:

```bash
claude --version
claude doctor
```

## 2. Temporary configuration

### Windows PowerShell

```powershell
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-flex247-key"
$env:ANTHROPIC_BASE_URL = "https://api.noflex.work"
$env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1"
claude
```

### macOS / Linux

```bash
export ANTHROPIC_AUTH_TOKEN="sk-your-flex247-key"
export ANTHROPIC_BASE_URL="https://api.noflex.work"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"
claude
```

## 3. Persistent settings

Add the following to your Claude Code user settings:

```json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-your-flex247-key",
    "ANTHROPIC_BASE_URL": "https://api.noflex.work",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

Close and reopen the terminal or editor after saving.

## 4. Verify

Run `claude`, then ask it to reply only with `Flex247 connected`. Confirm the request in Flex247 **Usage Logs**.

## VS Code and Cursor extensions

The extension uses the same environment variables. If the CLI works but the extension fails, fully exit the editor, reopen it and confirm that it reads the same user environment.

::: warning Permission safety
Do not enable unrestricted permission bypass by default. Adjust permission modes only for trusted projects or isolated environments.
:::


---

## Document: Connect CLIProxyAPI to Flex AI

Source: https://ai-apidocs.noflex.work/en/cliproxyapi

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/cliproxyapi](https://ai-apidocs.noflex.work/en/cliproxyapi)

# Connect CLIProxyAPI to Flex AI

CLIProxyAPI is a popular open-source local proxy that exposes OpenAI, Responses, Claude and Gemini-compatible interfaces for Codex, Claude Code, Gemini and other clients. It is the additional high-star local API routing tool selected for this section.

- [Official GitHub repository](https://github.com/router-for-me/CLIProxyAPI)
- [Official Releases](https://github.com/router-for-me/CLIProxyAPI/releases)
- [Official guide](https://help.router-for.me/)

::: info Why it was selected
Among high-star local proxy projects that are close to CC Switch and Cockpit Tools and explicitly support coding CLIs, CLIProxyAPI is a popular option with custom OpenAI-compatible upstream support. Star counts change, so refer to the official repository for the current number.
:::

## Understand the two API keys

CLIProxyAPI uses two different types of keys:

| Key | Purpose |
| --- | --- |
| Flex247 upstream key | Used by CLIProxyAPI to call `https://api.noflex.work/v1` |
| Local client key | Used by Codex or another client to access CLIProxyAPI |

Use different values. Do not enter the local client key into Flex247, and do not expose the upstream Flex247 key directly to local clients.

## 1. Install

Download and extract the archive for your operating system from the official Releases page. On Windows, this is normally the `windows_amd64.zip` asset.

Desktop users may also use [EasyCLIProxyAPI](https://github.com/router-for-me/EasyCLIProxyAPI), which the project README recommends as a graphical manager. This guide uses the core CLIProxyAPI configuration so every routing value remains explicit.

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cliproxyapi-easycli-en.png" alt="EasyCLIProxyAPI English desktop management interface">
  <figcaption>Figure 1: EasyCLIProxyAPI, the desktop manager recommended by the CLIProxyAPI README, showing runtime status and local OpenAI, Claude and Gemini endpoints. Image from the <a href="https://github.com/router-for-me/EasyCLIProxyAPI/tree/main/docs/screenshots/en">project repository</a>.</figcaption>
</figure>

## 2. Create `config.yaml`

Copy the official `config.example.yaml` to `config.yaml`, then keep the required fields. This is a minimal, local-only Flex247 example:

```yaml
host: "127.0.0.1"
port: 8317

api-keys:
  - "replace-with-a-long-random-local-client-key"

openai-compatibility:
  - name: "flex247"
    base-url: "https://api.noflex.work/v1"
    api-key-entries:
      - api-key: "sk-your-flex247-key"
    models:
      - name: "gpt-5.6-luna"
        alias: "gpt-5.6-luna"
```

Add more exact IDs from [Model Square](https://noflex.work/pricing) under `models`:

```yaml
      - name: "your-second-model-id"
        alias: "your-second-model-id"
```

::: warning Keep it bound to localhost
An empty `host` in the official example listens on all interfaces. For a personal computer, explicitly use `127.0.0.1`. LAN access requires additional firewall rules, a strong random client key and proper access controls.
:::

## 3. Start and test

Start the service from the extracted directory.

### Windows PowerShell

```powershell
.\cli-proxy-api.exe -config config.yaml
```

### macOS / Linux

```bash
./cli-proxy-api -config config.yaml
```

Use the local client key to check the model list:

```powershell
curl.exe http://127.0.0.1:8317/v1/models `
  -H "Authorization: Bearer replace-with-a-long-random-local-client-key"
```

The response should include the model IDs configured under `models`.

## 4. Route Codex through the local service

Set the local client key in the current terminal:

```powershell
$env:FLEX247_LOCAL_PROXY_KEY = "replace-with-a-long-random-local-client-key"
```

Then add the following to user-level `~/.codex/config.toml` (`%USERPROFILE%\.codex\config.toml` on Windows):

```toml
model = "gpt-5.6-luna"
model_provider = "flex247_local"

[model_providers.flex247_local]
name = "Flex247 via CLIProxyAPI"
base_url = "http://127.0.0.1:8317/v1"
env_key = "FLEX247_LOCAL_PROXY_KEY"
wire_api = "responses"
```

Keep CLIProxyAPI running and launch `codex` from the same terminal. The request path is:

```text
Codex → http://127.0.0.1:8317/v1 → CLIProxyAPI → https://api.noflex.work/v1
```

## Troubleshooting

### `Invalid API key`

Codex must use the local client key under `api-keys`, not the Flex247 upstream key under `api-key-entries`.

### `unknown provider for model`

Make sure the requested model is listed under `openai-compatibility.models`, and that `name` and `alias` match the Codex configuration.

### Cannot connect to `127.0.0.1:8317`

Check that CLIProxyAPI is still running, the `config.yaml` path is correct, and the port is free.

### Upstream 404

The upstream `base-url` must be `https://api.noflex.work/v1`, without a missing or duplicated `/v1`.

## Official references

- [Configuration template](https://github.com/router-for-me/CLIProxyAPI/blob/main/config.example.yaml)
- [Project README](https://github.com/router-for-me/CLIProxyAPI#readme)


---

## Document: Connect Cockpit Tools to Flex AI

Source: https://ai-apidocs.noflex.work/en/cockpit-tools

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/cockpit-tools](https://ai-apidocs.noflex.work/en/cockpit-tools)

# Connect Cockpit Tools to Flex AI

Cockpit Tools is a third-party, local-first account manager for AI IDEs and Codex. It can manage custom Codex model providers and expose an authenticated local Codex API service.

- [Official GitHub repository](https://github.com/jlcodes99/cockpit-tools)
- [Official downloads](https://github.com/jlcodes99/cockpit-tools/releases)

::: info Third-party project
Cockpit Tools is maintained by its open-source authors and community. Flex247 and this site do not develop or own it. Download only from the official repository and back up your existing Codex configuration before switching.
:::

## 1. Install Cockpit Tools

Choose the package for your operating system from the official Releases page:

- Windows: `.msi` or `x64-setup.exe`
- macOS: `.dmg`
- Linux: `.deb`, `.rpm` or `.AppImage`

Start Codex at least once so Cockpit Tools can discover its local configuration and instances.

## 2. Create a dedicated Flex247 key

Sign in to [Flex247](https://noflex.work/sign-in), open **API Keys**, and create a key dedicated to Cockpit Tools, such as `Cockpit-Windows`.

::: danger Protect the key
Never expose a real API key in screenshots, public documentation or chat messages. Revoke and replace any key that has been disclosed.
:::

## 3. Open Model Providers

In Cockpit Tools, open **Accounts → Codex → Model Providers**, then click **+** in the upper-right corner.

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cockpit-tools-model-providers.png" alt="Cockpit Tools Codex model providers page with the plus button highlighted">
  <figcaption>Figure 1: Open Accounts → Codex → Model Providers, then click +. The screenshot shows the Chinese interface.</figcaption>
</figure>

## 4. Choose Custom

In the **Add Model Provider** dialog, choose **Custom** from the provider presets. Do not select a preset for an unrelated third-party service.

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cockpit-tools-select-custom-provider.png" alt="Cockpit Tools Add Model Provider dialog with Custom selected">
  <figcaption>Figure 2: Choose Custom before entering the Flex247 values. The screenshot shows the Chinese interface.</figcaption>
</figure>

## 5. Enter the Flex247 provider

Enter the common fields first:

| Cockpit Tools field | Value |
| --- | --- |
| Provider Name | `Flex247` |
| Base URL | `https://api.noflex.work/v1` |
| Protocol | **Responses Native** |
| WebSocket Transport | Leave off by default; enable only after confirming that the upstream supports Responses WebSocket |
| Website (Optional) | `https://noflex.work/` |
| API Key Page (Optional) | `https://noflex.work/keys` |

Use **Responses Native** for the normal setup. Set the Base URL only through `/v1`: do not append `/responses` or duplicate the suffix as `/v1/v1`.

### Chat-Completions-only compatibility path

Select **Chat Completions** only when the target upstream explicitly lacks native `/v1/responses` support and you intentionally want Cockpit Tools to convert the protocol through its local gateway. Selecting it reveals the **Model Catalog** and image-routing fields.

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cockpit-tools-provider-core-fields.png" alt="Cockpit Tools custom provider fields for name, Base URL, protocol, model catalog, and image input">
  <figcaption>Figure 3: Base fields and Chat Completions compatibility fields. The highlighted protocol and sample models are illustrative; use Responses Native for the normal Flex247 Codex setup.</figcaption>
</figure>

| Chat Completions field | How to fill it |
| --- | --- |
| Model Catalog | Enter one exact model ID from [Model Square](https://noflex.work/pricing) per line |
| Image Input | Enable only when every model in the catalog accepts image input |
| Vision Models | If only some models accept images, leave the provider-wide toggle off and enter one vision model ID per line |
| Image Route Model | Optional; set only when image requests should fall back to a confirmed vision model, otherwise leave blank |

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cockpit-tools-provider-image-options.png" alt="Cockpit Tools custom provider fields for vision models, image route model, website, and API key page">
  <figcaption>Figure 4: Optional image-routing fields in Chat Completions mode. Configure them only for verified model capabilities.</figcaption>
</figure>

::: warning Do not copy the screenshot examples
`deepseek-v4-flash`, `deepseek-v4-pro`, `qwen-vl-plus`, `gpt-4o` and `mimo-v2.5` in Figures 3 and 4 are Cockpit Tools interface examples, not model recommendations from this site. Use the current IDs and capabilities shown in Model Square.
:::

## 6. Add the API key and save

Scroll down and enter:

| Cockpit Tools field | Value |
| --- | --- |
| New Key Name (Optional) | A recognizable label such as `Cockpit-Windows` |
| New API Key | The dedicated Flex247 key created in Step 2 |

A new provider requires at least one API key. Review **Save Preview**, then click **Save**.

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cockpit-tools-provider-api-key-save.png" alt="Cockpit Tools custom provider fields for key name and API key with the save preview">
  <figcaption>Figure 5: Enter the key label and API key, review the save preview, then save. <code>sk-api-key-here</code> is a placeholder.</figcaption>
</figure>

::: tip Saving does not switch the active provider
Saving updates the Cockpit Tools provider store, but it does not immediately change the current Codex provider, Base URL or `auth.json`. The active Codex configuration changes only when the matching Codex API-key account is saved or switched, or when the provider is enabled and its instance is started.
:::

## 7. Test, enable and start Codex

1. Return to Model Providers. If the provider contains several keys, first select the key to use on its provider card.
2. Click **One-click Test**, select Flex247 and run the chat test. If Cockpit Tools cannot determine a model automatically, enter an exact Model Square ID.
3. Select the target Codex instance on the provider card.
4. Click the play button, **Enable and Start**. If it is unavailable, open **App Multi-Launch** and start that instance once to initialize it.
5. Send a short, read-only request in the newly launched Codex instance, then verify the successful request and expected model in Flex247 [Usage Logs](https://noflex.work/usage-logs).

## 8. Optional: run the local Codex API service

Use **Codex API Service** when several accounts or providers should share one local endpoint:

1. Keep the bind address on `127.0.0.1`. Do not bind to `0.0.0.0` without proper network access controls.
2. Create a separate local client key.
3. Add the Flex247 provider and API key to the service account or provider pool.
4. Enable the service and use the Base URL shown in the UI, normally `http://127.0.0.1:<port>/v1`.

The local client key authenticates clients to Cockpit Tools. The Flex247 key authenticates Cockpit Tools to the upstream API. Do not mix them up.

## Troubleshooting

### 404 or Responses error

- Verify that the Base URL includes `/v1`.
- Select **Responses Native**.
- Do not append `/responses` to the Base URL.

### Saving reports a missing API key

A new provider must contain at least one key. Return to the bottom of the form and paste the complete dedicated Flex247 key into **New API Key**.

### Image input fails in Chat Completions mode

- Confirm in Model Square that the target model supports image input.
- If only some models accept images, turn off provider-wide image support and list the exact IDs under **Vision Models**, one per line.
- Set **Image Route Model** only when automatic fallback is required.

### Codex still uses the old provider

Return to the provider card, select the correct Codex instance, then click **Enable and Start**. Saving the provider alone does not switch the active Codex configuration.

### The local API service is unreachable

Check that the service is running, the port is free, and the client is using the local client key rather than the upstream Flex247 key.

## Official references

- [Cockpit Tools README](https://github.com/jlcodes99/cockpit-tools#readme)
- [Model-provider manager source](https://github.com/jlcodes99/cockpit-tools/blob/main/src/components/codex/CodexModelProviderManager.tsx)
- [Codex API Service architecture](https://github.com/jlcodes99/cockpit-tools/blob/main/docs/CODEX_API_SERVICE_HANDOFF.md)


---

## Document: Codex

Source: https://ai-apidocs.noflex.work/en/codex

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/codex](https://ai-apidocs.noflex.work/en/codex)

# Codex

A Codex custom provider uses the Responses API. Select a Flex247 model that supports `/v1/responses`.

## 1. Set the API key

### Windows PowerShell

```powershell
$env:FLEX247_API_KEY = "sk-your-flex247-key"
```

### macOS / Linux

```bash
export FLEX247_API_KEY="sk-your-flex247-key"
```

## 2. Edit `config.toml`

User-level configuration is stored at:

- Windows: `%USERPROFILE%\.codex\config.toml`
- macOS / Linux: `~/.codex/config.toml`

Add:

```toml
model = "your-responses-model-id"
model_provider = "flex247"
model_reasoning_effort = "medium"

[model_providers.flex247]
name = "Flex247"
base_url = "https://api.noflex.work/v1"
env_key = "FLEX247_API_KEY"
wire_api = "responses"
```

::: tip Model requirement
Codex custom providers currently use `responses` as the wire API. Use a Responses-compatible model from Model Square.
:::

## 3. Start and verify

From a test project directory, run:

```bash
codex
```

Ask Codex to list the current directory without modifying files, then confirm the request in Flex247 **Usage Logs**.

## Troubleshooting

### Missing environment variable

Set `FLEX247_API_KEY` in the same terminal that launches Codex.

### 404 or Responses error

Verify `base_url = "https://api.noflex.work/v1"` and select a Responses-compatible model.

### Configuration does not apply

Provider, authentication and Base URL settings belong in user-level `config.toml`, not only in a project `.codex/config.toml`.


---

## Document: Join the Flex247 Community

Source: https://ai-apidocs.noflex.work/en/community

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/community](https://ai-apidocs.noflex.work/en/community)

# Join the Flex247 Community

Get integration help, share workflows and learn from other Flex247 users.

<div class="api-endpoint"><strong>Flex247 Community</strong><code>https://community.noflex.work</code></div>

[Join the community](https://community.noflex.work)

## Before asking for help

Include:

- Client or SDK name
- Operating system and client version
- Model ID
- Base URL without any key
- HTTP status and error message
- Approximate time and matching usage log

::: danger Never share secrets
Hide complete API keys, redemption codes, account details and server credentials before posting screenshots.
:::


---

## Document: Connect DeepSeek Harness to Flex AI

Source: https://ai-apidocs.noflex.work/en/deepseek-harness

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/deepseek-harness](https://ai-apidocs.noflex.work/en/deepseek-harness)

# Connect DeepSeek Harness to Flex AI

DeepSeek Harness (`dsh`) is an open-source agent harness developed by DeepSeek AI. Its local Web UI provides session and workspace management, agent presets, plugins and custom model providers. Flex AI (Flex247) can be connected through the OpenAI Responses protocol.

- [Official GitHub repository](https://github.com/deepseek-ai/deepseek-harness)
- [Official README](https://github.com/deepseek-ai/deepseek-harness/blob/master/README.md)
- [Official model-provider guide](https://github.com/deepseek-ai/deepseek-harness/blob/master/docs/user/guide/providers.md)

::: info Developer preview
DeepSeek Harness is still a developer preview. Later releases may change its interface, configuration fields or behavior. The screenshots and steps on this page reflect the current version.
:::

::: danger Do not expose it to the public Internet
Do not publish DeepSeek Harness through public port forwarding, an open reverse proxy or a public bind address. It may have access to API keys, session content, code and local tool permissions.

Keep the default service on `127.0.0.1:3080`. For access from another device, use Tailscale or a similar trusted private-network solution and allow only your own trusted devices.
:::

## 1. Install and start DeepSeek Harness

Install Node.js, then run the command provided by the project:

```bash
npx @deepseek-ai/dsh web
```

Open the local Web UI at:

<http://127.0.0.1:3080/>

Keep the terminal that runs this command open. If the page is unavailable, confirm that the command is still running and port `3080` is not already in use.

## 2. Create a dedicated Flex247 key

Sign in to [Flex247](https://noflex.work/sign-in), open **API Keys**, and create a key dedicated to DeepSeek Harness, such as `DeepSeek-Harness-Windows`.

::: danger Protect the key
An API key grants access to your account usage. Never place a real key in screenshots, public documentation, chats or source repositories. The API-key field is intentionally blank in this guide's screenshot.
:::

## 3. Open Add Custom Provider

In DeepSeek Harness:

1. Click **Settings** in the lower-left corner.
2. Open **Models**.
3. Click **Add Custom Provider**.

<figure class="doc-screenshot">
  <img src="/images/deepseek-harness/deepseek-harness-add-custom-provider.png" alt="DeepSeek Harness Models settings page with the Add Custom Provider entry">
  <figcaption>Figure 1: Open Settings → Models and click Add Custom Provider. The screenshot shows the Chinese interface.</figcaption>
</figure>

## 4. Enter the Flex AI provider

Use these values:

| DeepSeek Harness field | Value |
| --- | --- |
| Provider ID | `flexai` |
| Display name | `Flex AI` |
| API URL | `https://api.noflex.work/v1` |
| API protocol | `openai-responses` |
| API key | Your dedicated Flex247 key |
| Model catalog | Click **Add Model** and enter an exact model ID from Model Square |

The model ID must exactly match [Model Square](https://noflex.work/pricing). For example, start with `gpt-5.6-luna` and use `GPT 5.6 Luna` as its display name.

<figure class="doc-screenshot">
  <img src="/images/deepseek-harness/deepseek-harness-flexai-provider.png" alt="DeepSeek Harness custom-provider form with the Flex AI URL, Responses protocol and an example model">
  <figcaption>Figure 2: Example Flex AI custom provider. The API-key field is intentionally blank.</figcaption>
</figure>

::: tip Keep the URL and protocol separate
Set the API URL only through `/v1`. Do not append `/responses` or duplicate the suffix as `/v1/v1`. The `openai-responses` selection controls the request protocol.
:::

::: warning Treat the Provider ID as permanent
The Provider ID is referenced by requests, sessions, model defaults and credentials. To change it, create a new provider and remove the old one. The display name, URL, protocol, key and models remain editable.
:::

::: danger Currently known incompatible models
Based on current compatibility testing, do not use `grok-4.5-free` or `grok-4.6-free` in DeepSeek Harness. Because their architecture is incompatible with the harness, these models trigger an infinite loop. This is not an official DeepSeek Harness compatibility statement.

If either model is selected accidentally, stop the current task immediately, switch to a compatible model and test again in a new session.
:::

## 5. Create the provider and test

1. Add at least one model, then click **Create Provider**.
2. Return to the session view and click **Select Model** below the prompt box.
3. Select **Flex AI** and the model you added.
4. Start a new session and send a short, read-only test request.
5. Confirm the successful request and expected model ID in Flex247 **Usage Logs**.

Provider and model routing changes take effect on the next request; DeepSeek Harness does not need to be restarted.

After entering the URL and key, you can also click **Get Available Models** before saving. If the upstream does not expose a compatible `GET /models` endpoint, add the exact model ID manually.

## Troubleshooting

### Get Available Models returns 401

Verify that the API key is complete and active, with available quota and permission for the target model.

### 404 or Responses error

- The API URL must be `https://api.noflex.work/v1`.
- Select `openai-responses` as the API protocol.
- Do not append `/responses` to the API URL.

### The model is missing from the selector

Edit the Flex AI provider and confirm that the model catalog contains at least one exact model ID. Use **Add Model** when automatic discovery is unavailable.

### The session repeats indefinitely

Stop the task immediately, confirm that neither `grok-4.5-free` nor `grok-4.6-free` is selected, and start a new session with a compatible model.


---

## Document: FAQ

Source: https://ai-apidocs.noflex.work/en/faq

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/faq](https://ai-apidocs.noflex.work/en/faq)

# FAQ

## 401: Authentication failed

Check that the key is complete, contains no whitespace and is sent with the correct header:

```http
Authorization: Bearer sk-your-flex247-key
```

Disable and replace any key that has been exposed publicly.

## 404 / 405: Wrong path or protocol

- OpenAI Chat: `https://api.noflex.work/v1/chat/completions`
- Responses: `https://api.noflex.work/v1/responses`
- Anthropic Messages: `https://api.noflex.work/v1/messages`

## 429: Too many requests

Reduce concurrency and add exponential backoff. If the admin UI also returns 429, wait briefly and check whether your proxy or firewall applies an unusually low per-IP limit.

## No available channel

Check the API key group, model restrictions, account balance and exact model ID, then retry.

## No output for a long time

Check **Usage Logs** to confirm that the request arrived. Long reasoning and multimodal jobs may take more time; use streaming when available.

## CLI works but the IDE extension fails

The IDE may have cached old environment variables. Fully exit it, reopen it and verify the Base URL, key and model ID.

## How do I verify charges?

Use **Usage Logs** to review the model, input, cache, output and final charge. Current model pricing is shown in [Model Square](https://noflex.work/pricing).

## I still need help

Visit [Flex247 Community](https://community.noflex.work) with the timestamp, model ID, status code and a screenshot with secrets hidden. Never post a complete API key.


---

## Document: Quickstart

Source: https://ai-apidocs.noflex.work/en/getting-started

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/getting-started](https://ai-apidocs.noflex.work/en/getting-started)

# Quickstart

Create an account, generate an API key and send your first Flex247 request.

## 1. Create your account

[Create a Flex247 account](https://noflex.work/sign-up), or [sign in](https://noflex.work/sign-in) if you already have one.

## 2. Generate an API key

Open **API Keys** after signing in and create a new key. Use separate keys for different devices and applications so usage and revocation stay easy to manage.

::: warning Store it safely
The complete key is normally displayed only once. Never expose it in screenshots, chat messages or public repositories.
:::

## 3. Choose a model

Copy a current model ID from [Model Square](https://noflex.work/pricing). The value must match exactly.

## 4. Send your first request

Replace the placeholder key and model ID:

```bash
curl https://api.noflex.work/v1/chat/completions \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [
      {"role": "user", "content": "Reply only: Flex247 connected"}
    ]
  }'
```

If you receive a model response, the endpoint, key and model are configured correctly.

## 5. Use environment variables

### Windows PowerShell

```powershell
$env:FLEX247_API_KEY = "sk-your-flex247-key"
$env:FLEX247_BASE_URL = "https://api.noflex.work/v1"
```

### macOS / Linux

```bash
export FLEX247_API_KEY="sk-your-flex247-key"
export FLEX247_BASE_URL="https://api.noflex.work/v1"
```

## Next steps

- OpenAI-style SDKs: [OpenAI Compatible](./openai-compatible)
- Anthropic Messages: [Anthropic Protocol](./anthropic-compatible)
- Coding agents: [Claude Code](./claude-code), [Codex](./codex) or [OpenCode](./opencode)


---

## Document: Flex247 API Documentation

Source: https://ai-apidocs.noflex.work/en/

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/](https://ai-apidocs.noflex.work/en/)

# Flex247 API Documentation

Flex247 provides OpenAI-compatible and Anthropic-compatible access to multiple AI model ecosystems through one API gateway.

- Human documentation: https://ai-apidocs.noflex.work/en
- API base URL: https://api.noflex.work/v1
- Community: https://community.noflex.work
- Machine-readable index: https://ai-apidocs.noflex.work/llms.txt


---

## Document: Images & Video

Source: https://ai-apidocs.noflex.work/en/media

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/media](https://ai-apidocs.noflex.work/en/media)

# Images & Video

Multimodal parameters differ by model. Check [Model Square](https://noflex.work/pricing) for capabilities, billing units and supported dimensions.

## Image generation

```bash
curl https://api.noflex.work/v1/images/generations \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-image-model-id",
    "prompt": "A clean product hero image, soft studio lighting",
    "size": "1024x1024",
    "n": 1
  }'
```

Responses may contain image URLs or Base64 data. Read the returned fields instead of assuming that every model uses the same format.

## Video generation

Video is commonly asynchronous: submit a job, store its task ID, poll status and download the completed result.

```bash
curl https://api.noflex.work/v1/videos \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-video-model-id",
    "prompt": "A cinematic product reveal with slow camera movement"
  }'
```

::: warning Model-specific behavior
Paths and fields for duration, aspect ratio, first or last frames and task status may differ. Follow the model requirements shown by Flex247 when a model has dedicated parameters.
:::

## Production guidance

- Use dedicated keys and quotas for image and video workloads.
- Store task IDs to avoid duplicate submissions and charges after a network interruption.
- Validate user prompts and input size.
- Copy completed assets to your own object storage instead of relying on temporary URLs.


---

## Document: Models & Endpoints

Source: https://ai-apidocs.noflex.work/en/models-and-endpoints

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/models-and-endpoints](https://ai-apidocs.noflex.work/en/models-and-endpoints)

# Models & Endpoints

Flex247 supports two common API patterns. Choose the one required by your SDK or client.

<div class="api-endpoint"><strong>OpenAI Compatible</strong><code>https://api.noflex.work/v1</code></div>

<div class="api-endpoint"><strong>Anthropic Protocol</strong><code>https://api.noflex.work</code></div>

## Common paths

| Use case | Method | Path |
| --- | --- | --- |
| Chat Completions | `POST` | `/v1/chat/completions` |
| Responses | `POST` | `/v1/responses` |
| Anthropic Messages | `POST` | `/v1/messages` |
| Model list | `GET` | `/v1/models` |
| Image generation | `POST` | `/v1/images/generations` |

::: tip Should the Base URL include `/v1`?
OpenAI-style SDKs normally use `https://api.noflex.work/v1`. Anthropic clients such as Claude Code normally use `https://api.noflex.work` and append `/v1/messages` themselves.
:::

## Model IDs

Copy the current model ID from [Model Square](https://noflex.work/pricing). Do not guess the ID or add spaces and version suffixes.

```json
{
  "model": "your-model-id"
}
```

## Choose the protocol

- A client asking for `base_url`, `api_key` or Chat Completions usually needs OpenAI Compatible.
- A client asking for `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN` or Messages needs Anthropic Protocol.
- A Codex custom provider requires a Responses-compatible model and `/v1/responses`.

## Groups and model restrictions

For “no available channel” or “model unavailable” errors, check the API key group, model restrictions and account balance before retrying.


---

## Document: OpenAI Compatible

Source: https://ai-apidocs.noflex.work/en/openai-compatible

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/openai-compatible](https://ai-apidocs.noflex.work/en/openai-compatible)

# OpenAI Compatible

Use this protocol with OpenAI-style SDKs, Chat Completions and supported Responses models.

<div class="api-endpoint"><strong>Base URL</strong><code>https://api.noflex.work/v1</code></div>

## cURL

```bash
curl https://api.noflex.work/v1/chat/completions \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Give me three product name ideas."}
    ]
  }'
```

## JavaScript / TypeScript

```bash
npm install openai
```

```js
import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: process.env.FLEX247_API_KEY,
  baseURL: 'https://api.noflex.work/v1'
})

const result = await client.chat.completions.create({
  model: 'your-model-id',
  messages: [{ role: 'user', content: 'Explain this function.' }]
})

console.log(result.choices[0].message.content)
```

## Python

```bash
pip install openai
```

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["FLEX247_API_KEY"],
    base_url="https://api.noflex.work/v1",
)

result = client.chat.completions.create(
    model="your-model-id",
    messages=[{"role": "user", "content": "Write a short launch checklist."}],
)

print(result.choices[0].message.content)
```

## Streaming

```js
const stream = await client.chat.completions.create({
  model: 'your-model-id',
  messages: [{ role: 'user', content: 'Write a short story.' }],
  stream: true
})

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? '')
}
```

## Responses API

Use `/v1/responses` only with models that support Responses:

```bash
curl https://api.noflex.work/v1/responses \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"your-responses-model-id","input":"Return only OK"}'
```


---

## Document: OpenCode

Source: https://ai-apidocs.noflex.work/en/opencode

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/opencode](https://ai-apidocs.noflex.work/en/opencode)

# OpenCode

Configure Flex247 in `opencode.json`. Choose one provider definition based on your model protocol.

## 1. Install and verify

```bash
npm install -g opencode-ai
opencode --version
```

## 2. OpenAI Compatible configuration

Create `opencode.json` in the project directory:

```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "flex247": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Flex247",
      "options": { "baseURL": "https://api.noflex.work/v1" },
      "models": {
        "your-model-id": { "name": "your-model-id" }
      }
    }
  },
  "model": "flex247/your-model-id"
}
```

## 3. Anthropic Protocol configuration

```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "flex247": {
      "npm": "@ai-sdk/anthropic",
      "name": "Flex247",
      "options": { "baseURL": "https://api.noflex.work" },
      "models": {
        "your-claude-model-id": { "name": "your-claude-model-id" }
      }
    }
  },
  "model": "flex247/your-claude-model-id"
}
```

## 4. Save the key

```bash
opencode providers login --provider flex247
```

Paste your Flex247 API key when prompted.

## 5. Test

Run `opencode` inside a test directory. Start with a read-only task and confirm the connection and permissions before using a production project.


---

## Document: Use the Flex AI API in OpenWrite

Source: https://ai-apidocs.noflex.work/en/openwrite

<!-- Flex247 machine-readable documentation | language: en -->
> Human-readable source: [https://ai-apidocs.noflex.work/en/openwrite](https://ai-apidocs.noflex.work/en/openwrite)

# Use the Flex AI API in OpenWrite

OpenWrite is an extensible AI writing platform for novels and long-form projects. It provides conversational writing, continuation, outlining, analysis and project-knowledge tools. Because it supports custom AI providers, it can connect to Flex AI (Flex247) through the OpenAI Compatible API.

::: warning Ownership and relationship notice
OpenWrite, its software, brand, interface and related intellectual property belong to the OpenWrite author. Flex247 and this site are not the developer or owner of OpenWrite. The site owner is simply one of its users and is sharing this guide after finding the app useful. This page does not imply an official partnership, authorization or endorsement by the OpenWrite author.
:::

## 1. Download and install OpenWrite

Before configuring Flex AI, download and launch OpenWrite.

**Download URL:** [http://openxz.cn/](http://openxz.cn/)

On the download page, choose the version for your device:

- **Windows**: Download the Windows x64 ZIP archive, extract it and run the app.
- **Android**: Download the Android ARM64 APK package.
- **macOS**: Download the macOS DMG package.

<figure class="doc-screenshot">
  <img src="/images/openwrite/openwrite-download-page.png" alt="OpenWrite download page with Windows x64, Android ARM64 and macOS downloads">
  <figcaption>Figure 1: Choose the OpenWrite version for your operating system.</figcaption>
</figure>

After downloading and launching OpenWrite, continue with the Flex AI configuration below.

## Before you begin

- A working [Flex247 account](https://noflex.work/sign-in).
- A valid Flex AI API key. Create a separate key for OpenWrite, such as `OpenWrite-Windows`.
- An exact model ID from [Model Square](https://noflex.work/pricing).

::: danger Keep your key private
An API key grants access to your account usage. Never expose a real key in chats, screenshots, documentation or public repositories. The key in this guide is masked.
:::

## 2. Open Settings

Start OpenWrite, then click the **gear icon (Settings)** in the upper-right corner.

<figure class="doc-screenshot">
  <img src="/images/openwrite/openwrite-settings-button.png" alt="The Settings button in the upper-right corner of OpenWrite">
  <figcaption>Figure 2: The Settings button is in the upper-right corner of the OpenWrite window.</figcaption>
</figure>

## 3. Choose a custom provider

In the Settings window:

1. Open the **AI Provider** tab.
2. Select **Custom Access** under **Quick Setup**.
3. Enter the Flex AI values below.

| OpenWrite field | Value |
| --- | --- |
| API URL | `https://api.noflex.work/v1` |
| API format | **OpenAI** |
| API Key | The key created in your Flex247 console |
| Model | An exact model ID from Model Square, such as `gpt-5.6-luna` in the screenshot |

<figure class="doc-screenshot">
  <img src="/images/openwrite/openwrite-flexai-provider.png" alt="Flex AI API URL, key and model configured in OpenWrite AI Provider settings">
  <figcaption>Figure 3: Example OpenAI Compatible configuration for Flex AI. The API key is masked.</figcaption>
</figure>

## 4. Load models and save

1. After entering the API URL and key, click **Get Model List**.
2. Select a model. If manual entry is supported, paste the exact model ID from Model Square.
3. Click **Save Configuration**.
4. Return to the main window and send a short test prompt.

::: tip Correct Base URL
OpenWrite requires `/v1` for the OpenAI Compatible endpoint. Do not use `https://api.noflex.work` without `/v1`, and do not duplicate it as `/v1/v1`.
:::

## Recommended models

For OpenWrite, we recommend trying these models first:

- **GPT 5.6 Luna**
- **DeepSeek V4 Flash**
- **GLM 5.2**
- **Qwen 3.8**
- **Kimi K3**

A model's display name may differ slightly from its full backend model ID. Click **Get Model List** and select it directly whenever possible. For manual entry, use the exact model ID shown in [Model Square](https://noflex.work/pricing).

## Create a dedicated API key

1. Sign in to [Flex247](https://noflex.work/sign-in).
2. Open **API Keys**.
3. Create a clearly named key, such as `OpenWrite-Windows`.
4. Apply the required group, model restrictions and quota.
5. Save the complete key immediately, then paste it into OpenWrite.

A dedicated key makes usage tracking, rotation and revocation easier without affecting your other applications.

## Troubleshooting

### The model list does not load

- Confirm the API URL is `https://api.noflex.work/v1`.
- Confirm **OpenAI** is selected as the API format.
- Check that the key is active, has available quota and can access the requested model group.
- Fully quit and reopen OpenWrite before trying again.

### Content generation fails after saving

- The model ID must exactly match Model Square.
- Remove quotation marks or spaces around the model ID.
- Test with a known working text model first.
- Check the Flex247 usage logs for the exact error.

::: info Screenshot version
The screenshots show OpenWrite `v1.3.2` for Windows. Button positions and labels may change slightly in later releases, while the API URL, OpenAI format and key requirements remain the same.
:::


# Language: 简体中文 (zh)

---

## Document: Anthropic Protocol

Source: https://ai-apidocs.noflex.work/anthropic-compatible

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/anthropic-compatible](https://ai-apidocs.noflex.work/anthropic-compatible)

# Anthropic Protocol

适用于 Claude Code、Anthropic SDK 和使用 Messages API 的应用。

<div class="api-endpoint"><strong>Base URL</strong><code>https://api.noflex.work</code></div>

## cURL

```bash
curl https://api.noflex.work/v1/messages \
  -H "x-api-key: sk-your-flex247-key" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "your-claude-model-id",
    "max_tokens": 512,
    "messages": [{"role": "user", "content": "Return only OK"}]
  }'
```

## JavaScript / TypeScript

```bash
npm install @anthropic-ai/sdk
```

```js
import Anthropic from '@anthropic-ai/sdk'

const client = new Anthropic({
  apiKey: process.env.FLEX247_API_KEY,
  baseURL: 'https://api.noflex.work'
})

const message = await client.messages.create({
  model: 'your-claude-model-id',
  max_tokens: 512,
  messages: [{ role: 'user', content: 'Review this API design.' }]
})

console.log(message.content[0].text)
```

## Python

```bash
pip install anthropic
```

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["FLEX247_API_KEY"],
    base_url="https://api.noflex.work",
)

message = client.messages.create(
    model="your-claude-model-id",
    max_tokens=512,
    messages=[{"role": "user", "content": "Summarize this change."}],
)

print(message.content[0].text)
```

## 常见配置错误

- `ANTHROPIC_BASE_URL` 不要重复写成 `/v1/v1`。
- 模型 ID 必须是 Flex247 模型广场中的完整名称。
- `x-api-key` 或 `ANTHROPIC_AUTH_TOKEN` 中不要包含额外空格。
- 如果客户端只支持 OpenAI 协议，请改用 [OpenAI Compatible](./openai-compatible)。


---

## Document: 文本与代码调用

Source: https://ai-apidocs.noflex.work/api-examples

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/api-examples](https://ai-apidocs.noflex.work/api-examples)

# 文本与代码调用

以下示例均使用 Flex247 OpenAI Compatible 端点。

## 基础聊天

```bash
curl https://api.noflex.work/v1/chat/completions \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [{"role":"user","content":"写一句产品标语"}]
  }'
```

## 带系统指令

```json
{
  "model": "your-model-id",
  "messages": [
    {"role": "system", "content": "你是一名资深代码审查员，先指出风险，再给出最小修改。"},
    {"role": "user", "content": "请检查下面的函数。"}
  ]
}
```

## 多轮对话

每次请求都带上需要保留的历史消息：

```js
const messages = [
  { role: 'user', content: '给项目取三个名字' },
  { role: 'assistant', content: 'Nova、Orbit、Canvas' },
  { role: 'user', content: '选择第二个，并写一句标语' }
]

const result = await client.chat.completions.create({
  model: 'your-model-id',
  messages
})
```

## JSON 输出

如果模型支持结构化输出，可要求返回 JSON。生产环境仍应验证字段与类型：

```json
{
  "model": "your-model-id",
  "messages": [
    {"role":"user","content":"返回 JSON：包含 title、summary、tags 三个字段"}
  ],
  "response_format": {"type":"json_object"}
}
```

## 超时与重试

- 只对超时、连接中断和部分 `5xx` 错误做有限次数重试。
- 对 `401` 先检查密钥，不要持续重试。
- 对 `429` 使用指数退避，并降低并发。
- 对长任务使用流式输出，避免客户端误以为请求卡住。


---

## Document: 账户与 API 密钥

Source: https://ai-apidocs.noflex.work/api-keys

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/api-keys](https://ai-apidocs.noflex.work/api-keys)

# 账户与 API 密钥

API 密钥代表你的账户权限。为每个应用单独创建密钥，可以让停用、轮换和用量排查更简单。

## 创建密钥

1. 登录 [Flex247](https://noflex.work/sign-in)。
2. 打开 **API 密钥**。
3. 输入容易辨认的名称，例如 `MacBook-Codex` 或 `Production-Store`。
4. 按需要设置分组、模型限制与额度。
5. 创建并立即保存完整密钥。

## 请求认证

OpenAI Compatible 请求使用 Bearer Token：

```http
Authorization: Bearer sk-your-flex247-key
```

Anthropic Protocol 请求可使用：

```http
x-api-key: sk-your-flex247-key
```

## 推荐做法

- 开发、测试和生产使用不同密钥。
- 不要把密钥写死在前端 JavaScript、移动应用或公开仓库。
- 通过环境变量或服务端密钥管理器加载。
- 发现异常调用时，先停用对应密钥，再创建替代密钥。
- 定期查看 **使用日志**，核对模型、令牌数量与费用。

## 轮换密钥

1. 创建新密钥。
2. 将应用更新到新密钥。
3. 发出测试请求并检查日志。
4. 确认没有旧流量后，停用旧密钥。

这样可以避免直接删除旧密钥造成服务中断。

## 多设备与多人协作

不要多人共用同一把密钥。每个人或服务独立创建密钥，问题发生时才能快速定位来源。


---

## Document: IDE 与聊天客户端

Source: https://ai-apidocs.noflex.work/apps-and-ides

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/apps-and-ides](https://ai-apidocs.noflex.work/apps-and-ides)

# IDE 与聊天客户端

大多数支持自定义 Provider 的 IDE、插件和聊天客户端，都可以用同一组参数连接 Flex247。

## 通用 OpenAI Compatible 模板

| 字段 | 填写内容 |
| --- | --- |
| Provider / Type | OpenAI Compatible / Custom OpenAI |
| API Key | `sk-your-flex247-key` |
| Base URL | `https://api.noflex.work/v1` |
| Model | 模型广场中的完整模型 ID |

适合使用 OpenAI 风格接口的 Cline、Roo Code、Kilo Code、Cherry Studio 等客户端。

## 通用 Anthropic 模板

| 字段 | 填写内容 |
| --- | --- |
| Provider / Type | Anthropic / Custom Anthropic |
| API Key | `sk-your-flex247-key` |
| Base URL | `https://api.noflex.work` |
| Model | 支持 Anthropic Protocol 的模型 ID |

## 配置步骤

1. 打开客户端的 Provider、Models 或 API 设置。
2. 选择自定义 Provider。
3. 根据客户端协议填写 Base URL。
4. 粘贴 Flex247 API 密钥。
5. 手动输入模型 ID，或刷新模型列表。
6. 保存后发出一条短测试消息。

## 为什么测试失败

- Base URL 多写或少写了 `/v1`。
- 模型 ID 与模型广场不完全一致。
- 密钥的分组没有该模型渠道。
- 客户端固定使用某一种协议，但选择了另一种 Provider 类型。
- 客户端缓存了旧配置，需要完全退出后重启。

::: tip 不确定协议时
先尝试 OpenAI Compatible；如果客户端明确要求 `ANTHROPIC_BASE_URL` 或 Messages API，再改用 Anthropic Protocol。
:::


---

## Document: CC Switch 接入 Flex AI

Source: https://ai-apidocs.noflex.work/cc-switch

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/cc-switch](https://ai-apidocs.noflex.work/cc-switch)

# CC Switch 接入 Flex AI

CC Switch 是一个跨平台的第三方桌面工具，用于管理 Claude Code、Codex、OpenCode 等应用的供应商配置，并可通过本地路由服务记录请求、统计用量和执行故障转移。

- [唯一官方网站](https://ccswitch.io)
- [官方 GitHub 仓库](https://github.com/farion1231/cc-switch)
- [官方下载页面](https://github.com/farion1231/cc-switch/releases)

::: warning 只从官方渠道下载
CC Switch 官方文档明确建议只使用 `ccswitch.io`、GitHub Releases 或项目源码仓库。不要向非官方安装包提供 API Key 或登录凭据。
:::

## 1. 安装

- Windows：下载 `Windows.msi`，或使用 `Windows-Portable.zip` 免安装版。
- macOS：下载 `.dmg`，或执行 `brew install --cask cc-switch`。
- Linux：选择 `.deb`、`.rpm` 或 `.AppImage`。

安装后先确保 Codex 已安装并至少启动过一次。

## 2. 添加 Flex247 供应商

1. 在 CC Switch 顶部选择 **Codex**。
2. 点击右上角 **+**。
3. 选择 **应用专属供应商**，再选择 **自定义**。
4. 填写以下参数。

| 字段 | 填写内容 |
| --- | --- |
| 名称 | `Flex247` |
| API Endpoint / Base URL | `https://api.noflex.work/v1` |
| API Key | 你的 Flex247 专用密钥 |
| Wire API / API 格式 | **Responses** |
| 模型 | 模型广场中的完整 Responses 模型 ID |
| 需要本地路由映射 | 关闭；只有上游仅支持 Chat Completions 时才开启 |

填写 API Key 与端点后，可以点击模型输入框旁的 **获取模型**。CC Switch 会调用 `/v1/models` 并让你直接选择模型。

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cc-switch-codex-provider.png" alt="CC Switch 新增 Codex 供应商官方界面截图">
  <figcaption>图 1：CC Switch 官方 Codex 供应商表单示例。截图中的名称、端点和模型仅为官方示例；接入本站时请按上表替换成 Flex247 参数。图片来自<a href="https://github.com/farion1231/cc-switch/blob/main/docs/images/codex-deepseek-routing/02-deepseek-codex-routing-form.png">项目官方仓库</a>。</figcaption>
</figure>

推荐先测试 `gpt-5.6-luna`，或从[模型广场](https://noflex.work/pricing)选择其他支持 Responses API 的模型。

## 3. 保存并切换

1. 保存供应商。
2. 在主界面选中 `Flex247`，点击 **启用 / Enable**。
3. 重新启动 Codex 或打开新的终端窗口。
4. 发送一个只读测试请求，并在 Flex247 **使用日志**中确认调用。

如果自定义页面要求手动编辑 Codex 配置，核心内容如下；API Key 仍应保存在 CC Switch 的密钥字段中，不要写进公开文件。

```toml
model = "gpt-5.6-luna"
model_provider = "flex247"

[model_providers.flex247]
name = "Flex247"
base_url = "https://api.noflex.work/v1"
wire_api = "responses"
requires_openai_auth = true
```

## 4. 可选：开启本地路由

需要请求日志、用量统计或故障转移时：

1. 打开 **设置 → 高级 → 路由服务**。
2. 启动路由服务。
3. 在 **应用路由**区域开启 **Codex 路由**。

开启后，Codex 会连接 CC Switch 的本地入口，默认形如 `http://127.0.0.1:15721/v1`，再由 CC Switch 转发至 Flex247。不要把本地地址误填回 Flex247 供应商的上游 Base URL。

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cc-switch-local-routing.png" alt="CC Switch Codex 本地路由官方界面截图">
  <figcaption>图 2：CC Switch 官方文档中的 Codex 本地路由界面；开启后请使用界面显示的本地地址。图片来自<a href="https://github.com/farion1231/cc-switch/blob/main/docs/images/codex-deepseek-routing/03-local-route-codex-takeover.png">项目官方仓库</a>。</figcaption>
</figure>

## Chat Completions 模型

如果目标模型只支持 `/v1/chat/completions`：

1. 将供应商协议改为 **Chat Completions**。
2. 开启 **需要本地路由映射**。
3. 配置 Codex 模型映射并保持路由服务运行。

Codex 原生使用 Responses API，因此没有本地协议转换时，Chat Completions 模型不能直接工作。

## 常见问题

### 获取不到模型

检查 API Key、Base URL 和账户余额；Base URL 应是 `https://api.noflex.work/v1`。

### 启用后没有生效

重新启动 Codex 与终端，并确认 CC Switch 当前应用面板是 **Codex**，不是 Claude Code 或其他应用。

### 本地路由显示未运行

先在高级设置启动路由服务，再开启 Codex 路由。确认本机 `15721` 端口未被其他程序占用。

## 官方参考

- [安装指南](https://github.com/farion1231/cc-switch/blob/main/docs/user-manual/zh/1-getting-started/1.2-installation.md)
- [添加供应商](https://github.com/farion1231/cc-switch/blob/main/docs/user-manual/zh/2-providers/2.1-add.md)
- [应用路由](https://github.com/farion1231/cc-switch/blob/main/docs/user-manual/zh/4-proxy/4.2-routing.md)


---

## Document: Claude Code

Source: https://ai-apidocs.noflex.work/claude-code

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/claude-code](https://ai-apidocs.noflex.work/claude-code)

# Claude Code

Claude Code 可通过环境变量连接 Flex247 的 Anthropic Protocol。

## 1. 安装

### Windows PowerShell

```powershell
irm https://claude.ai/install.ps1 | iex
```

### macOS / Linux

```bash
curl -fsSL https://claude.ai/install.sh | bash
```

检查安装：

```bash
claude --version
claude doctor
```

## 2. 临时配置

### Windows PowerShell

```powershell
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-flex247-key"
$env:ANTHROPIC_BASE_URL = "https://api.noflex.work"
$env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1"
claude
```

### macOS / Linux

```bash
export ANTHROPIC_AUTH_TOKEN="sk-your-flex247-key"
export ANTHROPIC_BASE_URL="https://api.noflex.work"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"
claude
```

## 3. 持久化配置

在 Claude Code 的用户设置文件中加入：

```json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-your-flex247-key",
    "ANTHROPIC_BASE_URL": "https://api.noflex.work",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

保存后完全关闭并重新打开终端或编辑器。

## 4. 验证

```bash
claude
```

进入后输入：

```text
只回复 Flex247 connected
```

然后到 Flex247 的 **使用日志** 检查是否出现对应请求。

## VS Code / Cursor 插件

插件使用的环境变量与 CLI 相同。如果命令行可以使用但插件报认证错误，请完全退出编辑器后重新打开，并确认插件读取的是同一组用户环境变量。

::: warning 权限安全
不要默认开启跳过所有操作确认。只在你完全信任的项目或隔离环境中调整权限模式。
:::


---

## Document: CLIProxyAPI 接入 Flex AI

Source: https://ai-apidocs.noflex.work/cliproxyapi

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/cliproxyapi](https://ai-apidocs.noflex.work/cliproxyapi)

# CLIProxyAPI 接入 Flex AI

CLIProxyAPI 是一个高 Star 的开源本地代理，为 Codex、Claude Code、Gemini 等客户端提供 OpenAI、Responses、Claude 与 Gemini 兼容接口。它是本分类中额外选择的本地 API 路由工具。

- [官方 GitHub 仓库](https://github.com/router-for-me/CLIProxyAPI)
- [官方 Releases](https://github.com/router-for-me/CLIProxyAPI/releases)
- [官方使用指南](https://help.router-for.me/)

::: info 为什么选择它
在与 CC Switch、Cockpit Tools 用途接近、明确支持编码 CLI 的本地代理项目中，CLIProxyAPI 是 GitHub Star 数较高且支持自定义 OpenAI-compatible 上游的代表项目。Star 数会变化，因此请以官方仓库显示为准。
:::

## 认识两种 API Key

CLIProxyAPI 配置里会出现两类密钥：

| 密钥 | 用途 |
| --- | --- |
| Flex247 上游 Key | CLIProxyAPI 请求 `https://api.noflex.work/v1` 时使用 |
| 本地客户端 Key | Codex 或其他客户端访问 CLIProxyAPI 时使用 |

请为两者使用不同的值，不要把本地客户端 Key 填到 Flex247，也不要把 Flex247 Key 直接发给本地客户端。

## 1. 安装

从官方 Releases 下载与你的系统匹配的压缩包并解压。Windows 通常选择 `windows_amd64.zip`。

桌面用户也可以使用项目 README 推荐的 [EasyCLIProxyAPI](https://github.com/router-for-me/EasyCLIProxyAPI) 图形界面；本教程使用核心 CLIProxyAPI 配置，便于审查每个路由参数。

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cliproxyapi-easycli-zh.png" alt="EasyCLIProxyAPI 中文桌面管理界面截图">
  <figcaption>图 1：CLIProxyAPI README 推荐的 EasyCLIProxyAPI 桌面管理界面，可查看运行状态与 OpenAI、Claude、Gemini 本地入口。图片来自<a href="https://github.com/router-for-me/EasyCLIProxyAPI/tree/main/docs/screenshots/zh-CN">项目官方仓库</a>。</figcaption>
</figure>

## 2. 创建 `config.yaml`

复制官方 `config.example.yaml` 为 `config.yaml`，然后保留所需字段。下面是 Flex247 的最小安全示例：

```yaml
host: "127.0.0.1"
port: 8317

api-keys:
  - "replace-with-a-long-random-local-client-key"

openai-compatibility:
  - name: "flex247"
    base-url: "https://api.noflex.work/v1"
    api-key-entries:
      - api-key: "sk-your-flex247-key"
    models:
      - name: "gpt-5.6-luna"
        alias: "gpt-5.6-luna"
```

需要更多模型时，在 `models` 下继续添加，并使用[模型广场](https://noflex.work/pricing)显示的准确 ID：

```yaml
      - name: "your-second-model-id"
        alias: "your-second-model-id"
```

::: warning 保持本机监听
官方示例的空 `host` 会监听所有网络接口。个人电脑建议明确设置为 `127.0.0.1`。如需局域网访问，应另外配置防火墙、强随机客户端 Key 与访问控制。
:::

## 3. 启动并测试

在解压目录启动服务。

### Windows PowerShell

```powershell
.\cli-proxy-api.exe -config config.yaml
```

### macOS / Linux

```bash
./cli-proxy-api -config config.yaml
```

启动成功后，用本地客户端 Key 检查模型列表：

```powershell
curl.exe http://127.0.0.1:8317/v1/models `
  -H "Authorization: Bearer replace-with-a-long-random-local-client-key"
```

返回结果应包含你在 `models` 中配置的 ID。

## 4. 让 Codex 使用本地路由

先在当前终端设置本地客户端 Key：

```powershell
$env:FLEX247_LOCAL_PROXY_KEY = "replace-with-a-long-random-local-client-key"
```

然后在用户级 `~/.codex/config.toml`（Windows 为 `%USERPROFILE%\.codex\config.toml`）添加：

```toml
model = "gpt-5.6-luna"
model_provider = "flex247_local"

[model_providers.flex247_local]
name = "Flex247 via CLIProxyAPI"
base_url = "http://127.0.0.1:8317/v1"
env_key = "FLEX247_LOCAL_PROXY_KEY"
wire_api = "responses"
```

保持 CLIProxyAPI 运行，再从同一个终端启动 `codex`。请求路径为：

```text
Codex → http://127.0.0.1:8317/v1 → CLIProxyAPI → https://api.noflex.work/v1
```

## 常见问题

### `Invalid API key`

Codex 需要的是 `api-keys` 下的本地客户端 Key，不是 `api-key-entries` 下的 Flex247 上游 Key。

### `unknown provider for model`

确认请求模型已列在 `openai-compatibility.models` 中，并检查 `name` 与 `alias` 是否与 Codex 配置一致。

### 无法连接 `127.0.0.1:8317`

确认 CLIProxyAPI 进程仍在运行、`config.yaml` 路径正确，并检查端口是否被占用。

### 上游返回 404

确认 `base-url` 为 `https://api.noflex.work/v1`，不要遗漏 `/v1`，也不要重复成 `/v1/v1`。

## 官方参考

- [配置模板](https://github.com/router-for-me/CLIProxyAPI/blob/main/config.example.yaml)
- [项目 README](https://github.com/router-for-me/CLIProxyAPI#readme)


---

## Document: Cockpit Tools 接入 Flex AI

Source: https://ai-apidocs.noflex.work/cockpit-tools

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/cockpit-tools](https://ai-apidocs.noflex.work/cockpit-tools)

# Cockpit Tools 接入 Flex AI

Cockpit Tools 是一款第三方、本地优先的 AI IDE 与 Codex 账号管理工具。它可以管理自定义 Codex 模型供应商，也可以在本机启动带认证的 Codex API 服务。

- [官方 GitHub 仓库](https://github.com/jlcodes99/cockpit-tools)
- [官方下载页面](https://github.com/jlcodes99/cockpit-tools/releases)

::: info 第三方项目说明
Cockpit Tools 由其开源作者与社区维护，Flex247 与本站并非该项目的开发者或所有者。请只从官方仓库下载，并在切换前备份现有 Codex 配置。
:::

## 1. 安装 Cockpit Tools

在官方 Releases 页面选择与你的系统匹配的安装包：

- Windows：`.msi` 或 `x64-setup.exe`
- macOS：`.dmg`
- Linux：`.deb`、`.rpm` 或 `.AppImage`

安装后先启动一次 Codex，让 Cockpit Tools 能识别本机的 Codex 配置与实例。

## 2. 创建 Flex247 专用密钥

登录 [Flex247](https://noflex.work/sign-in)，进入 **API 密钥** 页面，创建一把专用于 Cockpit Tools 的密钥，例如 `Cockpit-Windows`。

::: danger 保护密钥
不要把真实 API Key 放进截图、公开文档或聊天记录。若密钥曾经公开，请立即停用并重新创建。
:::

## 3. 打开“模型供应商”

在 Cockpit Tools 中依次打开 **Accounts → Codex → 模型供应商**，然后点击页面右上角的 **+**。

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cockpit-tools-model-providers.png" alt="Cockpit Tools 的 Codex 模型供应商页面，右上角加号按钮已高亮">
  <figcaption>图 1：在“Accounts → Codex → 模型供应商”中点击右上角“+”。</figcaption>
</figure>

## 4. 选择“自定义”供应商

在 **新增模型供应商**窗口的供应商预设中选择 **自定义**。不要选择与 Flex247 无关的第三方预设。

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cockpit-tools-select-custom-provider.png" alt="Cockpit Tools 新增模型供应商窗口，已选择自定义供应商">
  <figcaption>图 2：选择“自定义”后再填写 Flex247 参数。</figcaption>
</figure>

## 5. 填写 Flex247 供应商

先填写通用字段：

| Cockpit Tools 字段 | 填写内容 |
| --- | --- |
| 供应商名称 | `Flex247` |
| Base URL | `https://api.noflex.work/v1` |
| 协议能力 | **Responses 原生** |
| WebSocket 传输 | 默认关闭；只有确认上游支持 Responses WebSocket 时才开启 |
| 官网（可选） | `https://noflex.work/` |
| API Key 页面（可选） | `https://noflex.work/keys` |

大多数供应商应优先选择 **Responses 原生**。Base URL 只填写到 `/v1`，不要追加 `/responses`，也不要重复写成 `/v1/v1`。

### 仅在需要 Chat Completions 兼容路径时

只有目标上游明确不支持原生 `/v1/responses`，并且你确定要让 Cockpit Tools 通过本地网关转换协议时，才选择 **Chat Completions 协议**。切换后会出现 **模型目录**和图片路由字段。

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cockpit-tools-provider-core-fields.png" alt="Cockpit Tools 自定义供应商的名称、Base URL、协议、模型目录和图片输入能力字段">
  <figcaption>图 3：基础字段与 Chat Completions 兼容字段。图中高亮的协议和示例模型只用于定位；Flex247 常规 Codex 接入请选择“Responses 原生”。</figcaption>
</figure>

| Chat Completions 字段 | 填写方法 |
| --- | --- |
| 模型目录 | 每行填写一个来自[模型广场](https://noflex.work/pricing)的完整模型 ID |
| 图片输入能力 | 仅当目录中的所有模型都支持图片时开启 |
| 支持图片的模型 | 若只有部分模型支持图片，保持上方开关关闭，并在此处每行填写一个视觉模型 ID |
| 图片请求默认模型 | 可选；只在确认要把带图请求回退到某个视觉模型时填写，否则留空 |

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cockpit-tools-provider-image-options.png" alt="Cockpit Tools 自定义供应商的图片模型、默认图片模型、官网和 API Key 页面字段">
  <figcaption>图 4：Chat Completions 模式下的可选图片路由字段；仅在模型能力已经确认时填写。</figcaption>
</figure>

::: warning 不要照抄截图中的示例值
图 3、图 4 中的 `deepseek-v4-flash`、`deepseek-v4-pro`、`qwen-vl-plus`、`gpt-4o` 和 `mimo-v2.5` 都是 Cockpit Tools 的界面示例，不是本站推荐模型。请以模型广场显示的当前模型 ID 和能力为准。
:::

## 6. 添加 API Key 并保存

继续向下滚动并填写：

| Cockpit Tools 字段 | 填写内容 |
| --- | --- |
| 新增 Key 名称（可选） | 便于识别的名称，例如 `Cockpit-Windows` |
| 新增 API Key | 第 2 步创建的 Flex247 专用密钥 |

新增供应商时至少需要一把 API Key。核对 **保存预览**后点击 **保存**。

<figure class="doc-screenshot">
  <img src="/images/api-routing-tools/cockpit-tools-provider-api-key-save.png" alt="Cockpit Tools 自定义供应商的 Key 名称、API Key 和保存预览区域">
  <figcaption>图 5：填写 Key 名称与 API Key，核对保存预览后保存；图中的 <code>sk-api-key-here</code> 是占位符。</figcaption>
</figure>

::: tip 保存不等于切换
保存会更新 Cockpit Tools 的模型供应商仓库，但不会立即修改当前 Codex 的 provider、Base URL 或 `auth.json`。只有保存或切换对应的 Codex API Key 账号，或者在供应商卡片启用并启动实例后，当前 Codex 配置才会更新。
:::

## 7. 测试、启用并启动 Codex

1. 回到模型供应商列表；如果该供应商保存了多把 Key，先在供应商卡片选择本次要用的 Key。
2. 点击 **一键测试**，选择 Flex247 供应商并运行对话测试。若测试无法自动确定模型，可手动填写模型广场中的完整模型 ID。
3. 在供应商卡片选择目标 Codex 实例。
4. 点击播放图标 **启用并启动**。如果按钮不可用，请先到 **应用多开**页面启动一次该实例以完成初始化。
5. 在新启动的 Codex 中发送一个简短、只读的测试请求，再到 Flex247 [使用日志](https://noflex.work/usage-logs)确认请求成功且模型符合预期。

## 8. 可选：启用本地 Codex API 服务

需要把多个账号或供应商统一成一个本地入口时，可以使用 Cockpit Tools 的 **Codex API 服务**：

1. 将监听地址保持为 `127.0.0.1`，不要在没有网络访问控制的情况下绑定到 `0.0.0.0`。
2. 创建一把独立的本地客户端 Key。
3. 把 Flex247 供应商与 API Key 加入服务使用的账号或供应商池。
4. 启用服务，并使用界面显示的本地 Base URL；通常形如 `http://127.0.0.1:<端口>/v1`。

本地客户端 Key 用于访问 Cockpit Tools；Flex247 API Key 用于 Cockpit Tools 请求上游。两者不要混用。

## 常见问题

### 测试返回 404 或 Responses 错误

- 检查 Base URL 是否完整包含 `/v1`。
- 确认协议为 **Responses 原生**。
- 不要在 Base URL 后追加 `/responses`。

### 保存时提示缺少 API Key

新增供应商必须至少填写一把 Key。回到表单底部，在 **新增 API Key**中粘贴完整的 Flex247 专用密钥后再保存。

### Chat Completions 模式无法发送图片

- 确认模型广场明确标注目标模型支持图片输入。
- 如果只有部分模型支持图片，请关闭供应商默认图片能力，并在 **支持图片的模型**中逐行列出准确 ID。
- 只有在需要自动回退时才填写 **图片请求默认模型**。

### 保存后 Codex 仍使用旧供应商

回到供应商卡片选择正确的 Codex 实例，点击 **启用并启动**。单独保存供应商不会切换当前 Codex 配置。

### 本地 API 服务无法访问

确认服务状态为运行中、端口未被占用，并且客户端使用的是本地客户端 Key，而不是 Flex247 上游 Key。

## 官方参考

- [Cockpit Tools README](https://github.com/jlcodes99/cockpit-tools#readme)
- [模型供应商管理器源码](https://github.com/jlcodes99/cockpit-tools/blob/main/src/components/codex/CodexModelProviderManager.tsx)
- [Codex API Service 架构说明](https://github.com/jlcodes99/cockpit-tools/blob/main/docs/CODEX_API_SERVICE_HANDOFF.md)


---

## Document: Codex

Source: https://ai-apidocs.noflex.work/codex

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/codex](https://ai-apidocs.noflex.work/codex)

# Codex

Codex 自定义 Provider 使用 Responses API。请先确认选择的 Flex247 模型支持 `/v1/responses`。

## 1. 设置 API 密钥

### Windows PowerShell

```powershell
$env:FLEX247_API_KEY = "sk-your-flex247-key"
```

### macOS / Linux

```bash
export FLEX247_API_KEY="sk-your-flex247-key"
```

## 2. 编辑 `config.toml`

用户级配置位于：

- Windows：`%USERPROFILE%\.codex\config.toml`
- macOS / Linux：`~/.codex/config.toml`

加入以下配置：

```toml
model = "your-responses-model-id"
model_provider = "flex247"
model_reasoning_effort = "medium"

[model_providers.flex247]
name = "Flex247"
base_url = "https://api.noflex.work/v1"
env_key = "FLEX247_API_KEY"
wire_api = "responses"
```

::: tip 模型要求
Codex 当前自定义 Provider 的 `wire_api` 使用 `responses`。如果模型只支持 Chat Completions，请在其他客户端使用该模型，或在模型广场选择支持 Responses 的模型。
:::

## 3. 启动与验证

在一个测试项目目录执行：

```bash
codex
```

输入：

```text
列出当前目录文件，只读，不要修改。
```

## 常见问题

### Missing environment variable

当前终端没有读取 `FLEX247_API_KEY`。重新设置环境变量后，再从同一个终端启动 Codex。

### 404 或 Responses 错误

确认 `base_url` 为 `https://api.noflex.work/v1`，并选择支持 Responses 的模型。

### 修改配置没有生效

Provider、认证与 Base URL 应放在用户级 `config.toml`，不要只写在项目的 `.codex/config.toml`。


---

## Document: 加入 Flex247 社区

Source: https://ai-apidocs.noflex.work/community

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/community](https://ai-apidocs.noflex.work/community)

# 加入 Flex247 社区

获取接入帮助、查看使用技巧，并与其他 Flex247 用户交流。

## 加入方式

访问：

<div class="api-endpoint"><strong>Flex247 Community</strong><code>https://community.noflex.work</code></div>

[立即加入社区](https://community.noflex.work)

## 提问前准备

为了更快定位问题，请提供：

- 使用的客户端或 SDK
- 操作系统与客户端版本
- 模型 ID
- Base URL（不要包含密钥）
- HTTP 状态码与错误信息
- 出错时间和对应使用日志

::: danger 不要公开密钥
截图前请遮住完整 API 密钥、兑换码、账户资料与服务器凭据。社区成员不需要你的完整密钥来排查问题。
:::


---

## Document: DeepSeek Harness 接入 Flex AI

Source: https://ai-apidocs.noflex.work/deepseek-harness

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/deepseek-harness](https://ai-apidocs.noflex.work/deepseek-harness)

# DeepSeek Harness 接入 Flex AI

DeepSeek Harness（`dsh`）是由 DeepSeek AI 开发的开源 Agent Harness。它提供本地 Web UI、会话与工作区管理、Agent 预设、插件系统和自定义模型提供方，可通过 OpenAI Responses 协议接入 Flex AI（Flex247）。

- [官方 GitHub 仓库](https://github.com/deepseek-ai/deepseek-harness)
- [官方中文 README](https://github.com/deepseek-ai/deepseek-harness/blob/master/README.zh.md)
- [官方模型提供方指南](https://github.com/deepseek-ai/deepseek-harness/blob/master/docs/user/guide/providers.zh.md)

::: info 开发者预览
DeepSeek Harness 仍处于开发者预览阶段，后续版本可能调整界面、配置字段或行为。本页截图与步骤以当前版本为准。
:::

::: danger 不要暴露到公网
请勿通过公网端口映射、开放式反向代理或直接监听公网地址来暴露 DeepSeek Harness。它可能接触 API Key、会话内容、代码和本地工具权限。

默认保持在 `127.0.0.1:3080`。如需跨设备访问，建议使用 Tailscale 或类似的可信私网组网方案，并只允许你自己的受信设备访问。
:::

## 1. 安装并启动 DeepSeek Harness

先安装 Node.js，然后在终端运行官方提供的启动命令：

```bash
npx @deepseek-ai/dsh web
```

启动后打开：

<http://127.0.0.1:3080/>

保持运行该命令的终端窗口开启。若页面无法访问，请先确认命令仍在运行，而且端口 `3080` 没有被其他程序占用。

## 2. 创建 Flex247 专用密钥

登录 [Flex247](https://noflex.work/sign-in)，进入 **API 密钥** 页面，创建一把专用于 DeepSeek Harness 的密钥，例如 `DeepSeek-Harness-Windows`。

::: danger 保护密钥
API Key 等同于账户调用凭证。不要把真实密钥放进截图、公开文档、聊天记录或代码仓库。本页配置截图故意将 API Key 留空。
:::

## 3. 打开“添加自定义提供方”

在 DeepSeek Harness 中：

1. 点击左下角的 **设置**。
2. 打开 **模型**。
3. 点击 **添加自定义提供方**。

<figure class="doc-screenshot">
  <img src="/images/deepseek-harness/deepseek-harness-add-custom-provider.png" alt="DeepSeek Harness 设置的模型页面，底部显示添加自定义提供方入口">
  <figcaption>图 1：在“设置 → 模型”中点击“添加自定义提供方”。</figcaption>
</figure>

## 4. 填写 Flex AI 提供方

按下表填写：

| DeepSeek Harness 字段 | 填写内容 |
| --- | --- |
| Provider ID | `flexai` |
| 显示名称 | `Flex AI` |
| API 地址 | `https://api.noflex.work/v1` |
| API 协议 | `openai-responses` |
| API 密钥 | 你在 Flex247 创建的专用密钥 |
| 模型目录 | 点击 **添加模型**，填写模型广场中的完整模型 ID |

模型 ID 必须与[模型广场](https://noflex.work/pricing)完全一致。例如可以先添加 `gpt-5.6-luna`，显示名称可填写 `GPT 5.6 Luna`。

<figure class="doc-screenshot">
  <img src="/images/deepseek-harness/deepseek-harness-flexai-provider.png" alt="DeepSeek Harness 自定义提供方表单，填写 Flex AI 地址、Responses 协议和示例模型">
  <figcaption>图 2：Flex AI 自定义提供方示例；API Key 留空是为了避免泄露。</figcaption>
</figure>

::: tip 地址与协议分开填写
API 地址只填写到 `/v1`，不要追加 `/responses`，也不要写成 `/v1/v1`。请求格式由 **API 协议**中的 `openai-responses` 决定。
:::

::: warning Provider ID 不宜修改
Provider ID 会用于请求、会话、默认模型和凭据引用。创建后如需更换 ID，应新建提供方并删除旧提供方；显示名称、地址、协议、密钥和模型仍可编辑。
:::

::: danger 当前已知不兼容模型
根据当前兼容性测试，请勿在 DeepSeek Harness 中使用 `grok-4.5-free` 或 `grok-4.6-free`。由于架构不适配，这两个模型会触发无限循环（infinite loop）问题；这不是 DeepSeek Harness 官方兼容性声明。

如果误选，请立即停止当前任务，改用兼容模型并新建会话后再测试。
:::

## 5. 创建提供方并测试

1. 确认至少添加了一个模型，然后点击 **创建提供方**。
2. 返回会话界面，点击输入框下方的 **选择模型**。
3. 选择 **Flex AI** 及刚添加的模型。
4. 建议新建会话，先发送一个简短、只读的测试请求。
5. 到 Flex247 的 **使用日志**确认请求成功，且模型 ID 与预期一致。

提供方与模型路由会在下一次请求时生效，不需要重启 DeepSeek Harness。

如果 API Key 与地址已经填写，也可以在保存前点击 **获取可用模型**。若上游不提供兼容的 `GET /models`，请改为手动添加模型 ID。

## 常见问题

### 获取可用模型返回 401

检查 API Key 是否完整、仍然有效，并确认它有可用额度和目标模型权限。

### 返回 404 或 Responses 错误

- API 地址应为 `https://api.noflex.work/v1`。
- API 协议应选择 `openai-responses`。
- 不要在 API 地址后手动追加 `/responses`。

### 模型没有出现在选择器中

编辑 Flex AI 提供方，确认 **模型目录**中至少保存了一个完整模型 ID；必要时手动点击 **添加模型**。

### 会话不断重复执行

立即停止当前任务，确认没有选择 `grok-4.5-free` 或 `grok-4.6-free`，然后使用兼容模型新建会话。


---

## Document: 常见问题

Source: https://ai-apidocs.noflex.work/faq

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/faq](https://ai-apidocs.noflex.work/faq)

# 常见问题

## 401：认证失败

检查密钥是否完整、是否包含空格，以及请求头是否正确：

```http
Authorization: Bearer sk-your-flex247-key
```

如果密钥曾经出现在公开位置，请立即停用并重新创建。

## 404 / 405：路径或协议错误

常见原因是把 OpenAI Compatible 与 Anthropic Protocol 的路径混用。

- OpenAI Chat：`https://api.noflex.work/v1/chat/completions`
- Responses：`https://api.noflex.work/v1/responses`
- Anthropic Messages：`https://api.noflex.work/v1/messages`

## 429：请求过多

降低并发并加入指数退避。若登录后台也出现 429，请等待短时间后重试，并检查反向代理或防火墙是否对同一 IP 设置了过低限制。

## 模型无可用渠道

到 **API 密钥** 检查分组和模型限制，再确认账户余额与模型 ID。修改后重新请求。

## 长时间没有输出

先到 **使用日志** 查看请求是否已到达。长推理或多模态任务可能需要更久；支持时建议开启流式输出。

## 本地 CLI 可以，IDE 插件不可以

IDE 可能缓存旧环境变量。完全退出应用后重新启动，并确认插件使用正确的 Base URL、密钥与模型 ID。

## 费用如何核对

在 **使用日志** 查看模型、输入、缓存、输出与最终扣费。模型价格以[模型广场](https://noflex.work/pricing)显示为准。

## 仍然无法解决

前往 [Flex247 Community](https://community.noflex.work)，提供时间、模型 ID、错误码和已隐藏密钥的截图。请不要发送完整 API 密钥。


---

## Document: 五分钟接入

Source: https://ai-apidocs.noflex.work/getting-started

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/getting-started](https://ai-apidocs.noflex.work/getting-started)

# 五分钟接入

本页带你完成注册、创建 API 密钥并发出第一条请求。

## 1. 创建 Flex247 账户

前往 [Flex247](https://noflex.work/sign-up) 注册账户。已有账户可直接[登录](https://noflex.work/sign-in)。

## 2. 创建 API 密钥

登录后进入 **API 密钥**，创建一把新的密钥。建议为不同设备或应用分别创建，方便后续停用与查看用量。

::: warning 请妥善保存
完整密钥通常只在创建时显示一次。不要把它贴进截图、聊天记录或公开代码仓库。
:::

## 3. 选择模型

在[模型广场](https://noflex.work/pricing)复制要使用的模型 ID。模型名称必须与页面显示完全一致。

## 4. 发出第一条请求

将 `sk-your-flex247-key` 和 `your-model-id` 替换为真实值：

```bash
curl https://api.noflex.work/v1/chat/completions \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [
      {"role": "user", "content": "只回复：Flex247 connected"}
    ]
  }'
```

收到模型回复后，说明 Base URL、密钥与模型均已配置正确。

## 5. 保存为环境变量

### Windows PowerShell

```powershell
$env:FLEX247_API_KEY = "sk-your-flex247-key"
$env:FLEX247_BASE_URL = "https://api.noflex.work/v1"
```

### macOS / Linux

```bash
export FLEX247_API_KEY="sk-your-flex247-key"
export FLEX247_BASE_URL="https://api.noflex.work/v1"
```

## 下一步

- 使用 OpenAI 风格 SDK：前往 [OpenAI Compatible](./openai-compatible)
- 使用 Anthropic Messages：前往 [Anthropic Protocol](./anthropic-compatible)
- 配置编程工具：选择 [Claude Code](./claude-code)、[Codex](./codex) 或 [OpenCode](./opencode)


---

## Document: Flex247 API 文档

Source: https://ai-apidocs.noflex.work/

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/](https://ai-apidocs.noflex.work/)

# Flex247 API 文档

Flex247 provides OpenAI-compatible and Anthropic-compatible access to multiple AI model ecosystems through one API gateway.

- Human documentation: https://ai-apidocs.noflex.work/
- API base URL: https://api.noflex.work/v1
- Community: https://community.noflex.work
- Machine-readable index: https://ai-apidocs.noflex.work/llms.txt


---

## Document: 图像与视频

Source: https://ai-apidocs.noflex.work/media

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/media](https://ai-apidocs.noflex.work/media)

# 图像与视频

多模态模型的参数可能不同。先在[模型广场](https://noflex.work/pricing)确认模型能力、计费方式与支持的尺寸。

## 图像生成

```bash
curl https://api.noflex.work/v1/images/generations \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-image-model-id",
    "prompt": "A clean product hero image, soft studio lighting",
    "size": "1024x1024",
    "n": 1
  }'
```

常见返回方式包括图片 URL 或 Base64 数据。请按响应字段保存文件，不要假设所有模型返回格式完全相同。

## 视频生成

视频通常是异步任务：提交请求后取得任务 ID，再轮询状态，完成后下载结果。

```bash
curl https://api.noflex.work/v1/videos \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-video-model-id",
    "prompt": "A cinematic product reveal with slow camera movement"
  }'
```

::: warning 模型差异
视频模型的路径、时长、比例、首尾帧与任务查询字段可能不同。如果模型详情页提供专用参数，以该模型要求为准。
:::

## 生产建议

- 为图片与视频设置独立 API 密钥和额度。
- 保存任务 ID，避免网络中断后重复提交并重复计费。
- 对用户输入做长度和内容检查。
- 下载完成后转存到自己的对象存储，不要长期依赖临时 URL。


---

## Document: 模型与端点

Source: https://ai-apidocs.noflex.work/models-and-endpoints

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/models-and-endpoints](https://ai-apidocs.noflex.work/models-and-endpoints)

# 模型与端点

Flex247 提供两种常用协议。选择协议时，以你正在使用的 SDK 或客户端要求为准。

<div class="api-endpoint"><strong>OpenAI Compatible</strong><code>https://api.noflex.work/v1</code></div>

<div class="api-endpoint"><strong>Anthropic Protocol</strong><code>https://api.noflex.work</code></div>

## 常用路径

| 用途 | 方法 | 路径 |
| --- | --- | --- |
| Chat Completions | `POST` | `/v1/chat/completions` |
| Responses | `POST` | `/v1/responses` |
| Anthropic Messages | `POST` | `/v1/messages` |
| 模型列表 | `GET` | `/v1/models` |
| 图像生成 | `POST` | `/v1/images/generations` |

::: tip Base URL 是否包含 `/v1`
OpenAI 风格 SDK 通常填写 `https://api.noflex.work/v1`；Claude Code 等 Anthropic 客户端通常填写 `https://api.noflex.work`，由客户端自动追加 `/v1/messages`。
:::

## 模型 ID

请从[模型广场](https://noflex.work/pricing)复制当前模型 ID。不要根据显示名称猜测，也不要自行添加空格或版本后缀。

```json
{
  "model": "your-model-id"
}
```

## 选择协议

- 客户端要求 `base_url`、`api_key` 或 Chat Completions：使用 OpenAI Compatible。
- 客户端要求 `ANTHROPIC_BASE_URL`、`ANTHROPIC_AUTH_TOKEN` 或 Messages：使用 Anthropic Protocol。
- Codex 自定义 Provider 需要 Responses 兼容模型与 `/v1/responses`。

## 分组与模型限制

如果返回“无可用渠道”或“模型不可用”，检查 API 密钥所选分组、模型限制和账户余额。修改后重新发起请求即可。


---

## Document: OpenAI Compatible

Source: https://ai-apidocs.noflex.work/openai-compatible

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/openai-compatible](https://ai-apidocs.noflex.work/openai-compatible)

# OpenAI Compatible

适用于使用 OpenAI 风格 SDK、Chat Completions 或 Responses API 的应用。

<div class="api-endpoint"><strong>Base URL</strong><code>https://api.noflex.work/v1</code></div>

## cURL

```bash
curl https://api.noflex.work/v1/chat/completions \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Give me three product name ideas."}
    ]
  }'
```

## JavaScript / TypeScript

```bash
npm install openai
```

```js
import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: process.env.FLEX247_API_KEY,
  baseURL: 'https://api.noflex.work/v1'
})

const result = await client.chat.completions.create({
  model: 'your-model-id',
  messages: [{ role: 'user', content: 'Explain this function.' }]
})

console.log(result.choices[0].message.content)
```

## Python

```bash
pip install openai
```

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["FLEX247_API_KEY"],
    base_url="https://api.noflex.work/v1",
)

result = client.chat.completions.create(
    model="your-model-id",
    messages=[{"role": "user", "content": "Write a short launch checklist."}],
)

print(result.choices[0].message.content)
```

## 流式输出

```js
const stream = await client.chat.completions.create({
  model: 'your-model-id',
  messages: [{ role: 'user', content: 'Write a short story.' }],
  stream: true
})

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? '')
}
```

## Responses API

只有标记支持 Responses 的模型才能用于 `/v1/responses`：

```bash
curl https://api.noflex.work/v1/responses \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"your-responses-model-id","input":"Return only OK"}'
```


---

## Document: OpenCode

Source: https://ai-apidocs.noflex.work/opencode

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/opencode](https://ai-apidocs.noflex.work/opencode)

# OpenCode

OpenCode 可通过 `opencode.json` 配置 Flex247。以下两种 Provider 按模型协议二选一。

## 1. 安装并检查

```bash
npm install -g opencode-ai
opencode --version
```

## 2. OpenAI Compatible 配置

在项目目录创建 `opencode.json`：

```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "flex247": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Flex247",
      "options": {
        "baseURL": "https://api.noflex.work/v1"
      },
      "models": {
        "your-model-id": {
          "name": "your-model-id"
        }
      }
    }
  },
  "model": "flex247/your-model-id"
}
```

## 3. Anthropic Protocol 配置

```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "flex247": {
      "npm": "@ai-sdk/anthropic",
      "name": "Flex247",
      "options": {
        "baseURL": "https://api.noflex.work"
      },
      "models": {
        "your-claude-model-id": {
          "name": "your-claude-model-id"
        }
      }
    }
  },
  "model": "flex247/your-claude-model-id"
}
```

## 4. 保存密钥

```bash
opencode providers login --provider flex247
```

按提示粘贴 Flex247 API 密钥。

## 5. 启动测试

```bash
opencode
```

先用测试目录运行，并要求工具执行只读任务，确认连接与权限均正确后再用于正式项目。


---

## Document: 在 OpenWrite 中使用 Flex AI API

Source: https://ai-apidocs.noflex.work/openwrite

<!-- Flex247 machine-readable documentation | language: zh -->
> Human-readable source: [https://ai-apidocs.noflex.work/openwrite](https://ai-apidocs.noflex.work/openwrite)

# 在 OpenWrite 中使用 Flex AI API

OpenWrite 是一个开放式 AI 写作平台，面向小说与长篇内容创作，提供对话、续写、拆解、扫描和项目资料管理等写作能力。它支持自定义 AI 提供商，因此可以通过 OpenAI Compatible 接口接入 Flex AI（Flex247）。

::: warning 版权与关系说明
OpenWrite 的软件、品牌、界面及相关知识产权归 OpenWrite 作者所有。Flex247 与本站并非 OpenWrite 的开发者或所有者；本站站长只是 OpenWrite 的用户之一，因为实际使用后觉得好用，所以在此分享接入方法。本页不代表 OpenWrite 作者与本站之间存在官方合作、授权或背书。
:::

## 1. 下载并安装 OpenWrite

在配置 Flex AI 之前，请先下载并启动 OpenWrite。

**下载地址：** [http://openxz.cn/](http://openxz.cn/)

打开下载页后，根据你的设备选择对应版本：

- **Windows**：下载 Windows x64 版，解压后即可运行。
- **Android**：下载 Android ARM64 APK 安装包。
- **macOS**：下载 macOS DMG 安装包。

<figure class="doc-screenshot">
  <img src="/images/openwrite/openwrite-download-page.png" alt="OpenWrite 下载页面，提供 Windows x64、Android ARM64 和 macOS 版本的下载入口">
  <figcaption>图 1：OpenWrite 下载页；请根据设备系统选择对应版本。</figcaption>
</figure>

下载并启动 OpenWrite 后，再继续下面的 Flex AI 配置。

## 开始前准备

- 一个可正常登录的 [Flex247 账户](https://noflex.work/sign-in)。
- 一把有效的 Flex AI API 密钥。建议为 OpenWrite 单独创建，例如命名为 `OpenWrite-Windows`。
- 一个可用的完整模型 ID。可在 [模型广场](https://noflex.work/pricing) 查看。

::: danger 不要公开密钥
API Key 等同于账户调用凭证。不要把真实密钥发到聊天、截图、文档或公开仓库中。本页截图里的密钥已经隐藏。
:::

## 2. 打开设置

启动 OpenWrite 后，点击窗口右上角的 **齿轮按钮（设置）**。

<figure class="doc-screenshot">
  <img src="/images/openwrite/openwrite-settings-button.png" alt="OpenWrite 主界面右上角的设置按钮">
  <figcaption>图 2：OpenWrite 主界面；设置按钮位于右上角。</figcaption>
</figure>

## 3. 选择自定义接入

在设置窗口中：

1. 打开 **AI 提供商** 标签。
2. 在 **快速设置** 中选择 **自定义接入**。
3. 按下表填写 Flex AI 参数。

| OpenWrite 字段 | 填写内容 |
| --- | --- |
| API 地址 | `https://api.noflex.work/v1` |
| API 格式 | **OpenAI** |
| API Key | 你在 Flex247 控制台创建的密钥 |
| 模型 | 模型广场中的完整模型 ID，例如截图中的 `gpt-5.6-luna` |

<figure class="doc-screenshot">
  <img src="/images/openwrite/openwrite-flexai-provider.png" alt="在 OpenWrite 的 AI 提供商设置中填写 Flex AI API 地址、密钥和模型">
  <figcaption>图 3：Flex AI 的 OpenAI Compatible 配置示例。截图中的 API Key 已隐藏。</figcaption>
</figure>

## 4. 获取模型并保存

1. 填好 API 地址和 API Key 后，点击 **获取模型列表**。
2. 选择需要使用的模型；如果应用允许手动输入，也可以粘贴模型广场中的完整模型 ID。
3. 点击 **保存配置**。
4. 返回主界面，发送一条简短测试消息，确认模型可以正常回复。

::: tip 推荐配置
OpenWrite 使用 OpenAI Compatible 接口时，Base URL 必须包含 `/v1`。不要填写成 `https://api.noflex.work`，也不要重复写成 `/v1/v1`。
:::

## 推荐模型

在 OpenWrite 中，建议优先尝试以下模型：

- **GPT 5.6 Luna**
- **DeepSeek V4 Flash**
- **GLM 5.2**
- **Qwen 3.8**
- **Kimi K3**

模型显示名称可能与后台使用的完整模型 ID 略有不同。建议先点击 **获取模型列表** 并直接选择；如果需要手动填写，请以 [模型广场](https://noflex.work/pricing) 显示的完整模型 ID 为准。

## 如何创建专用 API 密钥

1. 登录 [Flex247](https://noflex.work/sign-in)。
2. 进入 **API 密钥** 页面。
3. 创建一把名称清楚的独立密钥，例如 `OpenWrite-Windows`。
4. 按需要设置分组、模型限制和额度。
5. 创建后立即保存完整密钥，再粘贴到 OpenWrite。

为 OpenWrite 使用独立密钥，可以更容易查看用量、轮换密钥或在异常时单独停用，而不会影响其他应用。

## 常见问题

### 获取不到模型列表

- 检查 API 地址是否为 `https://api.noflex.work/v1`。
- 确认选择的是 **OpenAI** 格式。
- 确认密钥仍然有效、有可用额度，并且所属分组可以访问目标模型。
- 完全退出 OpenWrite 后重新打开，再尝试获取模型列表。

### 保存后无法生成内容

- 模型 ID 必须与模型广场完全一致。
- 不要在模型 ID 前后加入引号或空格。
- 先换成一个已确认可用的文本模型进行测试。
- 在 Flex247 的使用日志中检查具体错误信息。

::: info 截图版本
本页截图来自 OpenWrite `v1.3.2` Windows 版。后续版本的按钮位置或字段名称可能略有变化，但所需的 API 地址、OpenAI 格式和密钥填写方式相同。
:::


# Language: Bahasa Malaysia (ms)

---

## Document: Protokol Anthropic

Source: https://ai-apidocs.noflex.work/ms/anthropic-compatible

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/anthropic-compatible](https://ai-apidocs.noflex.work/ms/anthropic-compatible)

# Protokol Anthropic

Gunakan protokol ini dengan Claude Code, SDK Anthropic dan klien Messages API.

<div class="api-endpoint"><strong>Base URL</strong><code>https://api.noflex.work</code></div>

## cURL

```bash
curl https://api.noflex.work/v1/messages \
  -H "x-api-key: sk-your-flex247-key" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "your-claude-model-id",
    "max_tokens": 512,
    "messages": [{"role": "user", "content": "Return only OK"}]
  }'
```

## JavaScript / TypeScript

```bash
npm install @anthropic-ai/sdk
```

```js
import Anthropic from '@anthropic-ai/sdk'

const client = new Anthropic({
  apiKey: process.env.FLEX247_API_KEY,
  baseURL: 'https://api.noflex.work'
})

const message = await client.messages.create({
  model: 'your-claude-model-id',
  max_tokens: 512,
  messages: [{ role: 'user', content: 'Review this API design.' }]
})

console.log(message.content[0].text)
```

## Python

```bash
pip install anthropic
```

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["FLEX247_API_KEY"],
    base_url="https://api.noflex.work",
)

message = client.messages.create(
    model="your-claude-model-id",
    max_tokens=512,
    messages=[{"role": "user", "content": "Summarize this change."}],
)

print(message.content[0].text)
```

## Kesilapan konfigurasi biasa

- Elakkan `/v1/v1` berulang dalam `ANTHROPIC_BASE_URL`.
- Gunakan ID model penuh yang dipaparkan dalam Dataran Model Flex247.
- Buang ruang tambahan pada `x-api-key` atau `ANTHROPIC_AUTH_TOKEN`.
- Jika klien hanya menyokong permintaan gaya OpenAI, gunakan [Serasi OpenAI](./openai-compatible).


---

## Document: Permintaan Teks & Kod

Source: https://ai-apidocs.noflex.work/ms/api-examples

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/api-examples](https://ai-apidocs.noflex.work/ms/api-examples)

# Permintaan Teks & Kod

Contoh ini menggunakan endpoint Serasi OpenAI Flex247.

## Sembang asas

```bash
curl https://api.noflex.work/v1/chat/completions \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [{"role":"user","content":"Write one product tagline."}]
  }'
```

## Arahan sistem

```json
{
  "model": "your-model-id",
  "messages": [
    {"role": "system", "content": "Act as a senior code reviewer. State risks first, then propose the smallest safe change."},
    {"role": "user", "content": "Review the following function."}
  ]
}
```

## Sembang berbilang giliran

Sertakan sejarah yang perlu dikekalkan:

```js
const messages = [
  { role: 'user', content: 'Suggest three project names.' },
  { role: 'assistant', content: 'Nova, Orbit, Canvas' },
  { role: 'user', content: 'Choose the second and write a tagline.' }
]

const result = await client.chat.completions.create({
  model: 'your-model-id',
  messages
})
```

## Output JSON

Bagi model yang menyokong output berstruktur, minta JSON dan tetap sahkan skema dalam produksi:

```json
{
  "model": "your-model-id",
  "messages": [
    {"role":"user","content":"Return JSON with title, summary and tags."}
  ],
  "response_format": {"type":"json_object"}
}
```

## Tamat masa dan percubaan semula

- Cuba semula tamat masa, sambungan terputus dan ralat `5xx` tertentu dalam jumlah terhad.
- Jangan cuba `401` berulang kali; semak kunci dahulu.
- Gunakan exponential backoff untuk `429` dan kurangkan concurrency.
- Gunakan penstriman untuk tugas panjang apabila disokong.


---

## Document: Akaun & Kunci API

Source: https://ai-apidocs.noflex.work/ms/api-keys

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/api-keys](https://ai-apidocs.noflex.work/ms/api-keys)

# Akaun & Kunci API

Kunci API mewakili akses kepada akaun anda. Berikan setiap aplikasi kunci tersendiri supaya pemantauan, penukaran dan penyelesaian insiden lebih mudah.

## Cipta kunci

1. [Log masuk ke Flex247](https://noflex.work/sign-in).
2. Buka **Kunci API**.
3. Gunakan nama yang jelas seperti `MacBook-Codex` atau `Production-Store`.
4. Tetapkan kumpulan, had model dan kuota jika diperlukan.
5. Cipta kunci dan simpan nilai penuh dengan segera.

## Pengepala pengesahan

Permintaan Serasi OpenAI menggunakan Bearer token:

```http
Authorization: Bearer sk-your-flex247-key
```

Permintaan Protokol Anthropic boleh menggunakan:

```http
x-api-key: sk-your-flex247-key
```

## Amalan yang disyorkan

- Gunakan kunci berbeza untuk pembangunan, ujian dan produksi.
- Jangan tanam kunci dalam kod pelayar, aplikasi mudah alih atau repositori awam.
- Muatkan kunci melalui pemboleh ubah persekitaran atau pengurus rahsia sebelah pelayan.
- Nyahaktifkan kunci yang mencurigakan sebelum mencipta pengganti.
- Semak **Log Penggunaan** untuk mengesahkan model, token dan caj.

## Tukar kunci tanpa gangguan

1. Cipta kunci pengganti.
2. Kemas kini aplikasi.
3. Hantar permintaan ujian dan semak log.
4. Nyahaktifkan kunci lama selepas trafiknya berhenti.

## Pasukan dan peranti

Elakkan berkongsi satu kunci antara individu atau perkhidmatan. Kunci khusus pengguna dan perkhidmatan memudahkan pengesanan pemilik.


---

## Document: IDE & Klien Sembang

Source: https://ai-apidocs.noflex.work/ms/apps-and-ides

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/apps-and-ides](https://ai-apidocs.noflex.work/ms/apps-and-ides)

# IDE & Klien Sembang

Kebanyakan klien yang menyokong penyedia tersuai boleh menggunakan parameter Flex247 yang sama.

## Templat umum Serasi OpenAI

| Medan | Nilai |
| --- | --- |
| Provider / Type | OpenAI Compatible / Custom OpenAI |
| API Key | `sk-your-flex247-key` |
| Base URL | `https://api.noflex.work/v1` |
| Model | ID model tepat daripada Dataran Model |

Corak ini boleh digunakan dengan penyedia gaya OpenAI tersuai dalam klien seperti Cline, Roo Code, Kilo Code dan Cherry Studio.

## Templat umum Protokol Anthropic

| Medan | Nilai |
| --- | --- |
| Provider / Type | Anthropic / Custom Anthropic |
| API Key | `sk-your-flex247-key` |
| Base URL | `https://api.noflex.work` |
| Model | ID model yang serasi Anthropic |

## Aliran konfigurasi

1. Buka tetapan Provider, Models atau API klien.
2. Pilih penyedia tersuai.
3. Masukkan Base URL mengikut protokol.
4. Tampal kunci API Flex247.
5. Masukkan ID model atau segarkan senarai model.
6. Simpan dan hantar mesej ujian ringkas.

## Punca kegagalan biasa

- `/v1` tiada atau berulang.
- ID model tidak sepadan dengan Dataran Model.
- Kumpulan kunci tidak mempunyai saluran untuk model tersebut.
- Klien terkunci kepada satu protokol tetapi jenis penyedia yang lain dipilih.
- Konfigurasi lama dicache dan klien perlu dimulakan semula sepenuhnya.


---

## Document: Claude Code

Source: https://ai-apidocs.noflex.work/ms/claude-code

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/claude-code](https://ai-apidocs.noflex.work/ms/claude-code)

# Claude Code

Sambungkan Claude Code kepada Flex247 melalui pemboleh ubah persekitaran yang serasi Anthropic.

## 1. Pasang

### Windows PowerShell

```powershell
irm https://claude.ai/install.ps1 | iex
```

### macOS / Linux

```bash
curl -fsSL https://claude.ai/install.sh | bash
```

Sahkan pemasangan:

```bash
claude --version
claude doctor
```

## 2. Konfigurasi sementara

### Windows PowerShell

```powershell
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-flex247-key"
$env:ANTHROPIC_BASE_URL = "https://api.noflex.work"
$env:CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1"
claude
```

### macOS / Linux

```bash
export ANTHROPIC_AUTH_TOKEN="sk-your-flex247-key"
export ANTHROPIC_BASE_URL="https://api.noflex.work"
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC="1"
claude
```

## 3. Tetapan kekal

Tambah pada tetapan pengguna Claude Code:

```json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-your-flex247-key",
    "ANTHROPIC_BASE_URL": "https://api.noflex.work",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}
```

Tutup dan buka semula terminal atau editor selepas menyimpan.

## 4. Sahkan

Jalankan `claude`, minta ia membalas hanya `Flex247 connected`, kemudian semak permintaan dalam **Log Penggunaan** Flex247.

## Sambungan VS Code dan Cursor

Sambungan menggunakan pemboleh ubah yang sama. Jika CLI berfungsi tetapi sambungan gagal, keluar sepenuhnya daripada editor, buka semula dan sahkan persekitaran pengguna yang dibaca.

::: warning Keselamatan kebenaran
Jangan aktifkan pintasan semua pengesahan secara lalai. Ubah mod kebenaran hanya untuk projek dipercayai atau persekitaran terpencil.
:::


---

## Document: Codex

Source: https://ai-apidocs.noflex.work/ms/codex

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/codex](https://ai-apidocs.noflex.work/ms/codex)

# Codex

Penyedia tersuai Codex menggunakan Responses API. Pilih model Flex247 yang menyokong `/v1/responses`.

## 1. Tetapkan kunci API

### Windows PowerShell

```powershell
$env:FLEX247_API_KEY = "sk-your-flex247-key"
```

### macOS / Linux

```bash
export FLEX247_API_KEY="sk-your-flex247-key"
```

## 2. Edit `config.toml`

Konfigurasi peringkat pengguna disimpan di:

- Windows: `%USERPROFILE%\.codex\config.toml`
- macOS / Linux: `~/.codex/config.toml`

Tambah:

```toml
model = "your-responses-model-id"
model_provider = "flex247"
model_reasoning_effort = "medium"

[model_providers.flex247]
name = "Flex247"
base_url = "https://api.noflex.work/v1"
env_key = "FLEX247_API_KEY"
wire_api = "responses"
```

::: tip Keperluan model
Penyedia tersuai Codex menggunakan `responses` sebagai wire API. Pilih model yang menyokong Responses daripada Dataran Model.
:::

## 3. Mula dan sahkan

Jalankan `codex` dari direktori projek ujian. Minta Codex menyenaraikan fail semasa tanpa mengubahnya, kemudian semak permintaan dalam **Log Penggunaan** Flex247.

## Penyelesaian masalah

### Pemboleh ubah persekitaran tiada

Tetapkan `FLEX247_API_KEY` dalam terminal yang sama yang digunakan untuk menjalankan Codex.

### Ralat 404 atau Responses

Sahkan `base_url = "https://api.noflex.work/v1"` dan pilih model yang menyokong Responses.

### Konfigurasi tidak digunakan

Tetapan penyedia, pengesahan dan Base URL hendaklah berada dalam `config.toml` peringkat pengguna, bukan hanya `.codex/config.toml` projek.


---

## Document: Sertai Komuniti Flex247

Source: https://ai-apidocs.noflex.work/ms/community

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/community](https://ai-apidocs.noflex.work/ms/community)

# Sertai Komuniti Flex247

Dapatkan bantuan integrasi, kongsi aliran kerja dan belajar bersama pengguna Flex247 yang lain.

<div class="api-endpoint"><strong>Komuniti Flex247</strong><code>https://community.noflex.work</code></div>

[Sertai komuniti](https://community.noflex.work)

## Sebelum meminta bantuan

Sertakan:

- Nama klien atau SDK
- Sistem operasi dan versi klien
- ID model
- Base URL tanpa sebarang kunci
- Status HTTP dan mesej ralat
- Anggaran masa serta log penggunaan yang sepadan

::: danger Jangan kongsi rahsia
Sembunyikan kunci API penuh, kod penebusan, butiran akaun dan kelayakan pelayan sebelum menyiarkan tangkap layar.
:::


---

## Document: Soalan Lazim

Source: https://ai-apidocs.noflex.work/ms/faq

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/faq](https://ai-apidocs.noflex.work/ms/faq)

# Soalan Lazim

## 401: Pengesahan gagal

Pastikan kunci lengkap, tiada ruang tambahan dan dihantar dengan pengepala yang betul:

```http
Authorization: Bearer sk-your-flex247-key
```

Nyahaktif dan ganti kunci yang pernah didedahkan secara awam.

## 404 / 405: Laluan atau protokol salah

- OpenAI Chat: `https://api.noflex.work/v1/chat/completions`
- Responses: `https://api.noflex.work/v1/responses`
- Anthropic Messages: `https://api.noflex.work/v1/messages`

## 429: Terlalu banyak permintaan

Kurangkan concurrency dan gunakan exponential backoff. Jika halaman pentadbir turut memaparkan 429, tunggu sebentar dan semak had per-IP pada proksi atau firewall.

## Tiada saluran tersedia

Semak kumpulan kunci API, had model, baki akaun dan ID model yang tepat, kemudian cuba semula.

## Tiada output untuk tempoh lama

Semak **Log Penggunaan** untuk memastikan permintaan telah sampai. Tugas penaakulan panjang dan multimodal mungkin mengambil masa lebih lama; gunakan penstriman apabila tersedia.

## CLI berfungsi tetapi sambungan IDE gagal

IDE mungkin menyimpan pemboleh ubah persekitaran lama. Keluar sepenuhnya, buka semula dan semak Base URL, kunci serta ID model.

## Bagaimana mengesahkan caj?

Gunakan **Log Penggunaan** untuk menyemak model, input, cache, output dan caj akhir. Harga model semasa dipaparkan dalam [Dataran Model](https://noflex.work/pricing).

## Masih memerlukan bantuan

Lawati [Komuniti Flex247](https://community.noflex.work) dengan masa kejadian, ID model, kod status dan tangkap layar yang telah menyembunyikan rahsia. Jangan siarkan kunci API penuh.


---

## Document: Panduan Mula Pantas

Source: https://ai-apidocs.noflex.work/ms/getting-started

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/getting-started](https://ai-apidocs.noflex.work/ms/getting-started)

# Panduan Mula Pantas

Cipta akaun, jana kunci API dan hantar permintaan Flex247 pertama anda.

## 1. Cipta akaun

[Daftar akaun Flex247](https://noflex.work/sign-up), atau [log masuk](https://noflex.work/sign-in) jika anda sudah mempunyai akaun.

## 2. Jana kunci API

Selepas log masuk, buka **Kunci API** dan cipta kunci baharu. Gunakan kunci berasingan untuk peranti dan aplikasi yang berbeza supaya penggunaan dan pembatalan lebih mudah diurus.

::: warning Simpan dengan selamat
Kunci penuh biasanya dipaparkan sekali sahaja. Jangan dedahkannya dalam tangkap layar, mesej sembang atau repositori awam.
:::

## 3. Pilih model

Salin ID model semasa daripada [Dataran Model](https://noflex.work/pricing). Nilai tersebut mesti sepadan sepenuhnya.

## 4. Hantar permintaan pertama

Gantikan kunci dan ID model contoh:

```bash
curl https://api.noflex.work/v1/chat/completions \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [
      {"role": "user", "content": "Reply only: Flex247 connected"}
    ]
  }'
```

Jika respons model diterima, endpoint, kunci dan model telah dikonfigurasi dengan betul.

## 5. Gunakan pemboleh ubah persekitaran

### Windows PowerShell

```powershell
$env:FLEX247_API_KEY = "sk-your-flex247-key"
$env:FLEX247_BASE_URL = "https://api.noflex.work/v1"
```

### macOS / Linux

```bash
export FLEX247_API_KEY="sk-your-flex247-key"
export FLEX247_BASE_URL="https://api.noflex.work/v1"
```

## Langkah seterusnya

- SDK gaya OpenAI: [Serasi OpenAI](./openai-compatible)
- Anthropic Messages: [Protokol Anthropic](./anthropic-compatible)
- Agent pengekodan: [Claude Code](./claude-code), [Codex](./codex) atau [OpenCode](./opencode)


---

## Document: Dokumentasi API Flex247

Source: https://ai-apidocs.noflex.work/ms/

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/](https://ai-apidocs.noflex.work/ms/)

# Dokumentasi API Flex247

Flex247 provides OpenAI-compatible and Anthropic-compatible access to multiple AI model ecosystems through one API gateway.

- Human documentation: https://ai-apidocs.noflex.work/ms
- API base URL: https://api.noflex.work/v1
- Community: https://community.noflex.work
- Machine-readable index: https://ai-apidocs.noflex.work/llms.txt


---

## Document: Imej & Video

Source: https://ai-apidocs.noflex.work/ms/media

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/media](https://ai-apidocs.noflex.work/ms/media)

# Imej & Video

Parameter multimodal berbeza mengikut model. Semak [Dataran Model](https://noflex.work/pricing) untuk keupayaan, unit caj dan saiz yang disokong.

## Penjanaan imej

```bash
curl https://api.noflex.work/v1/images/generations \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-image-model-id",
    "prompt": "A clean product hero image, soft studio lighting",
    "size": "1024x1024",
    "n": 1
  }'
```

Respons mungkin mengandungi URL imej atau data Base64. Baca medan respons dan jangan anggap semua model menggunakan format yang sama.

## Penjanaan video

Video lazimnya tak segerak: hantar tugas, simpan ID tugas, semak status dan muat turun hasil selepas selesai.

```bash
curl https://api.noflex.work/v1/videos \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-video-model-id",
    "prompt": "A cinematic product reveal with slow camera movement"
  }'
```

::: warning Perbezaan mengikut model
Laluan dan medan untuk tempoh, nisbah aspek, bingkai awal atau akhir serta status tugas mungkin berbeza. Ikut keperluan khusus model yang dipaparkan oleh Flex247.
:::

## Cadangan produksi

- Gunakan kunci dan kuota khusus untuk imej dan video.
- Simpan ID tugas bagi mengelakkan penghantaran dan caj berganda selepas gangguan rangkaian.
- Sahkan prompt pengguna dan saiz input.
- Salin aset siap ke storan objek sendiri dan jangan bergantung pada URL sementara.


---

## Document: Model & Endpoint

Source: https://ai-apidocs.noflex.work/ms/models-and-endpoints

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/models-and-endpoints](https://ai-apidocs.noflex.work/ms/models-and-endpoints)

# Model & Endpoint

Flex247 menyokong dua corak API biasa. Pilih corak yang diperlukan oleh SDK atau klien anda.

<div class="api-endpoint"><strong>Serasi OpenAI</strong><code>https://api.noflex.work/v1</code></div>

<div class="api-endpoint"><strong>Protokol Anthropic</strong><code>https://api.noflex.work</code></div>

## Laluan biasa

| Kegunaan | Kaedah | Laluan |
| --- | --- | --- |
| Chat Completions | `POST` | `/v1/chat/completions` |
| Responses | `POST` | `/v1/responses` |
| Anthropic Messages | `POST` | `/v1/messages` |
| Senarai model | `GET` | `/v1/models` |
| Penjanaan imej | `POST` | `/v1/images/generations` |

::: tip Perlukah Base URL mengandungi `/v1`?
SDK gaya OpenAI biasanya menggunakan `https://api.noflex.work/v1`. Klien Anthropic seperti Claude Code biasanya menggunakan `https://api.noflex.work` dan menambah `/v1/messages` secara automatik.
:::

## ID model

Salin ID model semasa daripada [Dataran Model](https://noflex.work/pricing). Jangan meneka ID atau menambah ruang dan akhiran versi.

```json
{
  "model": "your-model-id"
}
```

## Pilih protokol

- Klien yang meminta `base_url`, `api_key` atau Chat Completions biasanya memerlukan Serasi OpenAI.
- Klien yang meminta `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN` atau Messages memerlukan Protokol Anthropic.
- Penyedia tersuai Codex memerlukan model yang menyokong Responses dan `/v1/responses`.

## Kumpulan dan had model

Untuk ralat “tiada saluran tersedia” atau “model tidak tersedia”, semak kumpulan kunci API, had model dan baki akaun sebelum mencuba semula.


---

## Document: Serasi OpenAI

Source: https://ai-apidocs.noflex.work/ms/openai-compatible

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/openai-compatible](https://ai-apidocs.noflex.work/ms/openai-compatible)

# Serasi OpenAI

Gunakan protokol ini dengan SDK gaya OpenAI, Chat Completions dan model Responses yang disokong.

<div class="api-endpoint"><strong>Base URL</strong><code>https://api.noflex.work/v1</code></div>

## cURL

```bash
curl https://api.noflex.work/v1/chat/completions \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model-id",
    "messages": [
      {"role": "system", "content": "You are a concise assistant."},
      {"role": "user", "content": "Give me three product name ideas."}
    ]
  }'
```

## JavaScript / TypeScript

```bash
npm install openai
```

```js
import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: process.env.FLEX247_API_KEY,
  baseURL: 'https://api.noflex.work/v1'
})

const result = await client.chat.completions.create({
  model: 'your-model-id',
  messages: [{ role: 'user', content: 'Explain this function.' }]
})

console.log(result.choices[0].message.content)
```

## Python

```bash
pip install openai
```

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["FLEX247_API_KEY"],
    base_url="https://api.noflex.work/v1",
)

result = client.chat.completions.create(
    model="your-model-id",
    messages=[{"role": "user", "content": "Write a short launch checklist."}],
)

print(result.choices[0].message.content)
```

## Output penstriman

```js
const stream = await client.chat.completions.create({
  model: 'your-model-id',
  messages: [{ role: 'user', content: 'Write a short story.' }],
  stream: true
})

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? '')
}
```

## Responses API

Gunakan `/v1/responses` hanya dengan model yang menyokong Responses:

```bash
curl https://api.noflex.work/v1/responses \
  -H "Authorization: Bearer sk-your-flex247-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"your-responses-model-id","input":"Return only OK"}'
```


---

## Document: OpenCode

Source: https://ai-apidocs.noflex.work/ms/opencode

<!-- Flex247 machine-readable documentation | language: ms -->
> Human-readable source: [https://ai-apidocs.noflex.work/ms/opencode](https://ai-apidocs.noflex.work/ms/opencode)

# OpenCode

Konfigurasikan Flex247 dalam `opencode.json`. Pilih satu definisi penyedia mengikut protokol model.

## 1. Pasang dan sahkan

```bash
npm install -g opencode-ai
opencode --version
```

## 2. Konfigurasi Serasi OpenAI

Cipta `opencode.json` dalam direktori projek:

```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "flex247": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Flex247",
      "options": { "baseURL": "https://api.noflex.work/v1" },
      "models": {
        "your-model-id": { "name": "your-model-id" }
      }
    }
  },
  "model": "flex247/your-model-id"
}
```

## 3. Konfigurasi Protokol Anthropic

```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "flex247": {
      "npm": "@ai-sdk/anthropic",
      "name": "Flex247",
      "options": { "baseURL": "https://api.noflex.work" },
      "models": {
        "your-claude-model-id": { "name": "your-claude-model-id" }
      }
    }
  },
  "model": "flex247/your-claude-model-id"
}
```

## 4. Simpan kunci

```bash
opencode providers login --provider flex247
```

Tampal kunci API Flex247 apabila diminta.

## 5. Uji

Jalankan `opencode` dalam direktori ujian. Mulakan dengan tugas baca sahaja dan sahkan sambungan serta kebenaran sebelum menggunakan projek produksi.


