The client reads files, applies edits and runs commands requested by the model. Use an agent client and a model route that supports tools. Configure action permissions in the client.
Start building with Neiroport
Models and API formats through one Neiroport key
Connect in 30 seconds
All models work through Neiroport without a VPN, from any country. Choose a model identifier in the catalogue, create a key and set the service Base URL in your SDK
https://api.neiroport.com/v1Authorization: Bearer NEIROPORT_API_KEYCreate a key
Create a key in the console and save its secret immediately.
Fund the balance
Available balance and key budget must cover the request.
Send a request
Use an SDK example and the exact catalogue model identifier.
Before your first request
Use this service’s Base URL; include /v1 for the OpenAI SDK.
Use the exact model ID and variant from the catalogue.
Use an active Neiroport key that permits the selected model.
Ensure sufficient balance and key budget; otherwise the request is rejected before running the model.
Provide request_id from the response or usage history when contacting support.
Your first SDK call
Examples use an identifier from the current catalogue. Choose the available variant you need.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.NEIROPORT_API_KEY,
baseURL: "https://api.neiroport.com/v1"
});
const response = await client.chat.completions.create({
model: "abliterated-model-large",
messages: [{ role: "user", content: "Hello!" }],
max_tokens: 1024
});
console.log(response.choices[0].message.content);Agents in IDEs and terminals
Set up an assistant that opens your project files, writes code and runs commands. First complete the Neiroport dashboard steps, then choose your editor. You will use your API key and model ID to configure the agent on your computer.
1. Prepare your key and model
- Sign in to Neiroport and open API keys in the left menu. Create a key or reveal an existing one, then use its copy button. Copy the entire value starting with orb_. Paste this value into the editor's API Key field.
- Open Model suppliers. In API key, choose the same key. In Model, choose a text model, then select an available offer and apply it to the key. The selected variant must support tools / tool calling for agent tasks.
- Copy the selected model's exact ID, for example gpt-4o-mini. Use its technical ID, not the card's display name, in Model ID. Check your dashboard balance and the key's spending limit. Enter the ID below to update the configuration examples for your model.
https://api.neiroport.com/v1orb_…Your key from the Neiroport dashboardModel and route limitsNeiroport sets no shared token cap; the selected model and provider limits applygpt-4o-mini is an example, not the only model. Enter your variant's exact ID to update the configurations. These guides use text input and disable image attachments. Base URL already includes /v1; do not append it again.
2. Choose your editor and client
Guide for PyCharm is shown below. Continue, Cline, OpenCode and Claude Code let you choose another connection method. Follow one method; you do not need to install every client.
| Editor / IDE | Connection method | Mode |
|---|---|---|
| Any editor's terminal | Files, commands and agent tasks | |
| VS Code | Agent / Act - project tasks | |
| Cursor, Windsurf | Inside the Cline extension | |
| PyCharm, IntelliJ IDEA, WebStorm, GoLand, Rider, PhpStorm, CLion, RubyMine, RustRover | Agent through ACP or Cline | |
| Zed | Files and terminal tasks | |
| Neovim | Files and terminal tasks | |
| Visual Studio, Eclipse, Sublime Text, Emacs, Python IDLE and others | Plugin dependent; OpenCode in a terminal |
In Cursor and Windsurf, configure the connection inside the Cline extension. Menu names may vary slightly between versions. If agent installation is unavailable, update the editor or use the terminal method.
OpenCode · terminal and ACP
Use one Neiroport profile in the terminal and ACP editors. Configure OpenCode first, then connect it to your editor.
- Install Node.js LTS from nodejs.org if needed, then reopen your terminal. On Windows: Start → type cmd → open Command Prompt. On macOS/Linux, open Terminal. Paste the installation command below, press Enter and wait for it to finish. Run opencode --version to confirm that it prints a version.
- Create the shared opencode.json file using your system's instructions below. Copy the OpenCode · opencode.json example into it. The API address and model ID already come from the table above. Do not paste your key into this file: add it separately in the next step. The example sets no artificial context or output limits. If your client needs these parameters, use the actual limits of the selected model and route.
npm install -g opencode-aiWindows: where to save opencode.json
- Press Win+R, enter %USERPROFILE% and press Enter to open your user folder. Create .config inside it, then an opencode folder inside .config, if missing.
- Open Notepad, paste the JSON below and choose File → Save As. Open .config\opencode, use the filename opencode.json, select All files and UTF-8. It must not be named opencode.json.txt. If the file exists, merge the neiroport settings into it while preserving other sections.
macOS / Linux: where to save opencode.json
Run these commands in Terminal. Paste the JSON into nano, press Ctrl+O and Enter to save, then Ctrl+X to exit. If XDG_CONFIG_HOME is set, use that directory instead of ~/.config.
mkdir -p ~/.config/opencode
nano ~/.config/opencode/opencode.json{
"$schema": "https://opencode.ai/config.json",
"model": "neiroport/gpt-4o-mini",
"provider": {
"neiroport": {
"npm": "@ai-sdk/openai-compatible",
"name": "Neiroport",
"options": {
"baseURL": "https://api.neiroport.com/v1"
},
"models": {
"gpt-4o-mini": {
"name": "gpt-4o-mini",
"tool_call": true,
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
}
}
}
}
}
}- Open a terminal in your project folder. On Windows, open the folder in Explorer, type cmd in its address bar and press Enter. Run opencode. Once its interface appears, type /connect into the task input. Select Other, enter neiroport and press Enter. Paste the full orb_ key into the API key prompt and confirm. Enter /connect inside OpenCode, not in Windows Command Prompt.
- In /models select neiroport/
gpt-4o-mini. The provider ID must match neiroport in the configuration. For another model, configure its route on your key, add its ID to models and update model.
After choosing the model, select Build mode (Tab switches modes). Send the sample task below with Enter. The agent works in the folder you launched it from. To use an editor panel instead, follow the relevant steps below. ACP lets the editor run the same agent; Neiroport supplies the model and OpenCode opens files on your computer.
JetBrains · PyCharm / IntelliJ IDEA / WebStorm / others
These steps apply to PyCharm, IntelliJ IDEA, WebStorm, GoLand, Rider, PhpStorm, CLion, RubyMine and RustRover. First save the profile and connect your key in OpenCode as shown above. ACP agents do not require a JetBrains AI subscription; API requests use your Neiroport balance.
- Open your project. Go to Settings → Plugins → Marketplace and search for JetBrains AI Assistant. Install it if missing and restart the IDE. On macOS, open Settings from the editor's application menu.
- Go to Settings → Tools → AI Assistant → Agents. Open the registry, find OpenCode and click Install. Alternatively: AI Chat panel → mode selector → Install From ACP Registry. Click OK after installation.
- Open View → Tool Windows → AI Chat. Select OpenCode in the agent selector, then choose Neiroport and your model in the model list. Start a new session and send the sample task below. Restart the agent session after changing its key or profile.
- If Agents is missing, update the IDE and AI Assistant. Until then, use the configured agent in View → Tool Windows → Terminal by running opencode. It can work with the same project files.
If OpenCode is missing from the registry: manual setup
Click Add Custom Agent under Agents to open ~/.jetbrains/acp.json. Merge this example into the file. Replace FULL_PATH_TO_OPENCODE with the executable's absolute path. Find it with where opencode in Windows Command Prompt or command -v opencode on macOS/Linux. Double Windows backslashes in JSON: C:\\Users\\... Your key is already stored through /connect; do not paste it here.
{
"agent_servers": {
"Neiroport / OpenCode": {
"command": "FULL_PATH_TO_OPENCODE",
"args": [
"acp"
]
}
}
}On Windows, use native OpenCode for JetBrains ACP: running ACP agents from WSL is currently unsupported. Restart the agent session after configuring its key and model.
Zed · ACP
- Open the project folder with File → Open. Complete the OpenCode setup above: save opencode.json, connect your key and choose the model.
- Press Ctrl+Shift+P (Cmd+Shift+P on macOS), type zed: acp registry and run it. Find and install OpenCode in the registry.
- Open the command palette again, run agent: new thread and select OpenCode. Choose your Neiroport model in the model selector. Send the sample task below and approve proposed actions.
To connect an existing installation manually, run zed: open settings from the command palette and merge this agent_servers example into your settings.
{
"agent_servers": {
"Neiroport / OpenCode": {
"type": "custom",
"command": "opencode",
"args": [
"acp"
]
}
}
}If opencode is absent from the editor process's PATH, use its absolute executable path. Set the model and key in the shared OpenCode profile above.
Neovim · Avante.nvim / ACP
First run without additional plugins
- Configure OpenCode using the guide above. In Neovim, press Esc, type :pwd and press Enter to check the working folder. If needed, use :cd YOUR_PROJECT_PATH with your actual project path.
- Run :terminal opencode and press i in the terminal. Choose your model using /models and send a task. The agent can read and edit the current project's files.
- Leave terminal input mode with Ctrl+\, then Ctrl+N. Reload externally changed files using :checktime. For a separate Avante panel, use the option below.
If Avante.nvim is already installed
Install Avante.nvim with ACP support. Add acp_providers to your existing plugin's setup options. Run :AvanteSwitchProvider, select opencode and open :AvanteChat. Use :AvanteModels for model selection.
acp_providers = {
opencode = {
command = "opencode",
args = { "acp" },
},
},3. Verify the connection
Copy the task below into the agent's input and send it. It should list files and propose creating a file. Approve the action and check that AGENT_TEST.md appears in your project folder. Then ask it to delete the test file. Requests appear in your Neiroport usage log; one task may involve several requests.
List the files in the project root. Create a new AGENT_TEST.md file containing 'Neiroport agent connected'. If the file already exists, leave it unchanged and tell me. Do not modify other files.Connection errors and fixes
- npm / opencode: command not found
- Install Node.js LTS, close the terminal and open a new window. Repeat npm install -g opencode-ai. If the problem occurs in an IDE terminal, restart the editor too. On Windows, use Command Prompt (cmd) for these steps.
- JSON / YAML configuration error
- Check the filename: opencode.json or config.yaml, without .txt. Preserve the example's double quotes and commas in JSON. YAML indentation uses spaces, not tabs. For a first-time setup, copy the entire example and replace only the specified values.
- Empty model list
- Configure an available route on the same key in the dashboard, then refresh the client's model list. Connection testing and model assignment are separate steps.
- 401 · invalid_api_key
- Use the full Neiroport client key; check whitespace and expiry.
- 402 · insufficient_balance / key_budget
- Check your balance and the key's spending limit. Listing models does not check the balance required for generation.
- 403 / 404 · model
- Check the exact ID, allowed models and selected route. For a 404 without an Neiroport error code, check Base URL: include /v1 exactly once.
- 400 · invalid_output_limit / context_limit
- Max Output Tokens must be a positive integer. If the provider rejects the limit, check the selected model and route specifications. For context_limit, trim conversation history and project context to the model's supported size.
- 502 / 503
- Check the error code and request_id in the usage log. Verify route availability and tools support on the selected variant. Agent tasks require a route that supports tool calling.
- Agent unavailable / tools
- Check your plugin version's Agent support, capabilities/tool calling and route. Update a changed key separately in every client, including OpenCode.
Balance and webhooks
GET /v1/balance
Returns the account balance of the API key owner. Pass your Neiroport key as Authorization: Bearer. This request is free and works with a zero balance or an exhausted key budget. No model needs to be connected
curl https://api.neiroport.com/v1/balance \
-H "Authorization: Bearer $NEIROPORT_API_KEY"{
"currency": "USD",
"balance": "10.000000",
"reserved": "1.250000",
"available": "8.750000"
}| Field | Meaning |
|---|---|
currency | Always USD |
balance | Account balance after confirmed charges |
reserved | Funds reserved for requests awaiting completion |
available | Funds available for new requests: balance minus reserved |
Amounts are strings with six decimal places to preserve precision. Your interface currency does not change this response. This is the account balance, not the remaining budget of an individual API key. The endpoint allows 120 requests per minute per account. Invalid, revoked or expired keys return 401; disabled accounts return 403
Configure a notification
- Open Settings and find Balance notification
- Enter a public HTTPS domain or the full handler URL, such as https://example.com/webhooks/neiroport. A domain without a path receives requests at its root
- Enter a USD threshold, enable notifications and save. A threshold of 5 sends a notification when the account balance becomes less than $5
- Click Test request. Your handler must accept a JSON POST and return any 2xx status without a redirect
The threshold checks balance without subtracting temporary holds. One notification is created per low-balance period. Further charges below the threshold do not create new notifications. After a top-up reaches or exceeds the threshold, the next drop can trigger it again. Enabling notifications while the balance is already low creates one notification. Saving unchanged settings does not duplicate it
Request body
{"event":"balance.low"}The body contains only the event type, with no email, account ID, API keys or financial data. Fetch GET /v1/balance after the notification if you need current amounts. A test contains only {"event":"balance.test"} and does not affect the real notification state
Signature verification and delivery
The signing secret is available in the same settings block. Store it only on your server. Headers include X-Neiroport-Delivery (event ID), X-Neiroport-Timestamp (Unix seconds) and X-Neiroport-Signature. The signature is sha256= followed by HMAC-SHA256 of timestamp + a dot + the raw request body, using your webhook secret as the key
import { createHmac, timingSafeEqual } from "node:crypto";
// rawBody: Buffer with the original POST body
const timestamp = req.headers["x-neiroport-timestamp"];
const signature = req.headers["x-neiroport-signature"] || "";
const expected = "sha256=" + createHmac("sha256", process.env.NEIROPORT_WEBHOOK_SECRET)
.update(timestamp + ".").update(rawBody).digest("hex");
const age = Math.abs(Date.now() / 1000 - Number(timestamp));
const actualBytes = Buffer.from(signature);
const expectedBytes = Buffer.from(expected);
const valid = /^\d+$/.test(timestamp || "") && age <= 300
&& actualBytes.length === expectedBytes.length
&& timingSafeEqual(actualBytes, expectedBytes);
if (!valid) { res.writeHead(401); res.end(); return; }
const event = JSON.parse(rawBody.toString("utf8"));
// Deduplicate X-Neiroport-Delivery in your database, then handle event.event
res.writeHead(204);
res.end();Delivery runs in the background with up to three total attempts on network errors or non-2xx responses: retries after 30 seconds and 5 minutes. Each attempt has a 5-second deadline and retains the same X-Neiroport-Delivery. Store this identifier to avoid handling an event twice, for example if your server accepted it but its acknowledgement was lost. Redirects are not followed; local and private destinations are blocked, and HTTPS on port 443 is supported. Test deliveries are free, make one attempt and allow up to 5 requests per minute
Three API formats
Choose a request format supported by the model. All supported protocols use your Neiroport key and the service API URL.
OpenAI
/v1/chat/completionsBearer NEIROPORT_API_KEY
Chat · Responses · Images · EmbeddingsAnthropic
/v1/messagesx-api-key: NEIROPORT_API_KEY
anthropic-version: 2023-06-01Gemini
/v1beta/models/{model}:generateContentx-goog-api-key: NEIROPORT_API_KEY
contents · parts · generationConfigcurl https://api.neiroport.com/v1/messages \
-H "x-api-key: $NEIROPORT_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello!"
}
]
}'curl "https://api.neiroport.com/v1beta/models/gemini-2.5-flash:generateContent" \
-H "x-goog-api-key: $NEIROPORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello!"
}
]
}
],
"generationConfig": {
"maxOutputTokens": 1024
}
}'PDF and audio in messages
In POST /v1/chat/completions, attachments are items in messages[].content alongside your question. These are standard OpenAI Chat Completions formats. Attachment support depends on the model and available route: a format being present in the SDK does not mean every model accepts it
The examples below were tested in Neiroport with gemini-3.1-flash-lite-preview. Enable this model on your API key and choose a range containing available offers. Set the NEIROPORT_API_KEY environment variable, install the openai package and place the file beside your script. These examples return text responses
PDF document
Use type: file, a filename ending in .pdf and file_data beginning with data:application/pdf;base64,. After the comma, provide the actual PDF bytes encoded as Base64. The example reads and encodes document.pdf for you
import OpenAI from "openai";
import { readFileSync } from "node:fs";
const client = new OpenAI({
apiKey: process.env.NEIROPORT_API_KEY,
baseURL: "https://api.neiroport.com/v1"
});
const data = readFileSync("document.pdf").toString("base64");
const response = await client.chat.completions.create({
model: "gemini-3.1-flash-lite-preview",
messages: [{
role: "user",
content: [
{ type: "text", text: "Summarize this document" },
{
type: "file",
file: {
filename: "document.pdf",
file_data: `data:application/pdf;base64,${data}`
}
}
]
}]
});
console.log(response.choices[0].message.content);WAV or MP3 audio
Use type: input_audio. The data field contains Base64 only, without a data:audio/… prefix; format must match the file: wav or mp3. For MP3, replace audio.wav with audio.mp3 and set format to mp3
import OpenAI from "openai";
import { readFileSync } from "node:fs";
const client = new OpenAI({
apiKey: process.env.NEIROPORT_API_KEY,
baseURL: "https://api.neiroport.com/v1"
});
const data = readFileSync("audio.wav").toString("base64");
const response = await client.chat.completions.create({
model: "gemini-3.1-flash-lite-preview",
messages: [{
role: "user",
content: [
{ type: "text", text: "What is said in this recording?" },
{ type: "input_audio", input_audio: { data, format: "wav" } }
]
}]
});
console.log(response.choices[0].message.content);Native Gemini format
In /v1beta/models/{model}:generateContent, use contents[].parts[].inlineData with mimeType and raw Base64 in data. Use application/pdf for PDF, audio/wav for WAV and audio/mpeg for MP3. Images support image/png, image/jpeg and image/webp. BASE64 below is a placeholder for the encoded file contents, not a value to send literally
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Summarize this document"
},
{
"inlineData": {
"mimeType": "application/pdf",
"data": "BASE64"
}
}
]
}
]
}image_url is for images only: do not send PDF or audio under that type. Loading by file_id, external file_url or file identifiers from other services is not supported here. Include the file contents in the request. The complete Neiroport JSON request, including Base64 and history, must not exceed 32 MiB; Base64 increases file size by about one third. The model's own limits still apply
Official schemas: OpenAI PDF · OpenAI Audio · Google Gemini Audio
Model catalogue and variants
The catalogue updates automatically. Identifiers and suffixes are preserved: variants have distinct model IDs and tariffs. Your preference determines the route.
curl https://api.neiroport.com/v1/models \
-H "Authorization: Bearer $NEIROPORT_API_KEY"Routing preferences
Models display savings against their original rate. For example, if your price is one fifth of the original, the label reads Save 80%. The comparison uses your final account price: input for token-based models, or the per-request rate. No savings label is shown without a reference rate
Personal route pool
- Open Model suppliers and choose a key and model. If you have no key, create one directly while selecting an offer
- Click Route pool and select offers. Choose a strategy: price, success rate, latency or your priorities
- For automatic selection, set a price range as percentages of the original rate and a minimum cache hit percentage. Optionally set input, output and cache rate ceilings
- Preview the matching routes, then save the pool. SDKs and agents use these settings without code changes
Automatic selection updates the pool every 10 minutes. Blacklisted routes are excluded. Requests stop before dispatch when routes fail the limits or rates have changed. Funds are reserved at the maximum pool rate and charged at the actual selected route rate. Delayed settlement confirmations are reconciled automatically
Compare offers in Model suppliers and pin a supplier separately for each model and client key. Displayed prices include markup. Pins take priority over automatic routing and apply in SDK calls without extra parameters.
Pinned routes do not fall back to other suppliers. If a tariff changes or a supplier becomes unavailable, the request is rejected before dispatch; select a supplier again or restore automatic routing. Select the same client key in the playground to test its route.
Choose a preference when creating an API key; you can change it later without replacing the key. All calls using this key follow the selected preference. The playground has a separate preference selector.
Price has the greatest weight. At similar prices, success rate and response speed are also considered.
Prefer routes with faster responses. Price remains a selection criterion.
Prefer higher request success rates and fewer failures
Combine success rate, response speed and route price
Use only guaranteed routes. Reject the request if none are available.
Prices and availability may differ by preference. The catalogue shows the selected preference’s tariff. Global and individual markup apply across all preferences; unconfirmed tariffs cannot be used for generation. The guaranteed preference uses only guaranteed routes.
Model details show API formats, billing type, input, output, cache read and write, or a per-request price. Reference prices are not active tariffs until confirmed.
Endpoint reference
Use the /v1 Base URL with SDKs. Main REST methods are also available at the service root: /chat/completions, /responses, /models. Gemini /v1beta paths start at the service root.
Account
/balanceAccount balance, reserved and available funds in USD
Text and agents
/chat/completionsConversation; JSON response or SSE.
/responsesResponses API with explicit input and output limit.
/messagesNative Anthropic Messages format.
/v1beta/models/{model}:generateContentNative Google Gemini format.
/completionsText prompt completion.
Multimodal and retrieval
/images/generationsImage generation; per-request billing.
/embeddingsText embeddings.
/rerankRank documents against a query.
Models, tasks and realtime
/modelsModels available to your key.
/models/{model}Details for one model identifier.
curl https://api.neiroport.com/v1/responses \
-H "Authorization: Bearer $NEIROPORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "abliterated-model-large",
"input": "Hello!",
"max_output_tokens": 1024,
"store": false
}'curl https://api.neiroport.com/v1/embeddings \
-H "Authorization: Bearer $NEIROPORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-embedding-2-preview",
"input": "Text to embed"
}'curl https://api.neiroport.com/v1/images/generations \
-H "Authorization: Bearer $NEIROPORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.1-flash-image",
"prompt": "A quiet mountain lake",
"n": 1,
"size": "1024x1024"
}'Troubleshooting
Use error.code and request_id to diagnose a failure. API errors and an extended compatibility reference are listed separately. Internal routing details are not exposed to clients.
{
"error": {
"code": "model_not_found",
"message": "model_not_found"
},
"request_id": "http_xxxxxxxxxxxx"
}invalid_api_keyCorrection required- Failure location
auth/key- Description
- The key is missing, invalid, revoked or disabled.
- Resolution
- Check the key, expiry and authentication header. Client requests require a key issued by this service.
model_not_allowedCorrection required- Failure location
auth/model- Description
- The key does not permit this model.
- Resolution
- Check account status, key permissions and restrictions for this model or operation. Retrying with unchanged permissions will fail.
account_disabledCorrection required- Failure location
auth/account- Description
- The account is disabled.
- Resolution
- Check account status, key permissions and restrictions for this model or operation. Retrying with unchanged permissions will fail.
insufficient_balanceCorrection required- Failure location
billing/balance- Description
- Available balance cannot cover the request reservation.
- Resolution
- Check available balance, key budget and selected tariff. Resolve the relevant limit before retrying.
key_budgetCorrection required- Failure location
billing/key_budget- Description
- The API key budget cannot cover this request.
- Resolution
- Check available balance, key budget and selected tariff. Resolve the relevant limit before retrying.
model_not_foundCorrection required- Failure location
routing/model- Description
- The model is missing or has not been activated.
- Resolution
- Check the path, exact model or task identifier and availability. Removed content may no longer be recoverable.
invalid_inputCorrection required- Failure location
request/validation- Description
- The request body or required fields are invalid.
- Resolution
- Check required fields, data format and model capabilities. Correct the request before submitting a new operation.
unsupported_inputCorrection required- Failure location
request/format- Description
- This gateway adapter does not support the input format.
- Resolution
- Check required fields, data format and model capabilities. Correct the request before submitting a new operation.
unsupported_billingCorrection required- Failure location
billing/tariff- Description
- No confirmed supported tariff exists for this operation.
- Resolution
- Check required fields, data format and model capabilities. Correct the request before submitting a new operation.
context_limitCorrection required- Failure location
request/context- Description
- The request and output limit exceed the model’s context window.
- Resolution
- Check required fields, data format and model capabilities. Correct the request before submitting a new operation.
invalid_output_limitCorrection required- Failure location
request/output- Description
- The output token limit is invalid.
- Resolution
- Check required fields, data format and model capabilities. Correct the request before submitting a new operation.
request_already_submittedCorrection required- Failure location
request/idempotency- Description
- This Idempotency-Key identifies an operation already submitted.
- Resolution
- Check the original request_id in usage history. The same Idempotency-Key cannot create a second charge; use a new key for a new operation.
Billing and streaming usage
Tariff
Charges use the published tariff for the selected model and preference. Input, output and cache rates or a fixed per-request price apply. Tariff changes apply to new requests.
Usage
Token tariffs account for input, output, cache reads and writes. Confirmed per-request tariffs charge the configured fixed amount.
Rounding and settlement
The actual token charge is rounded up to $0.000002, followed by a $0.000001 settlement fee. A completed paid token request costs at least $0.000003. Per-million token rates and partner rate ceilings remain unchanged; settlement is separate. Free tariffs, rejected requests and requests without confirmed usage incur no such charge. Fixed per-request tariffs have no added fee
History and reservations
The maximum estimate is reserved before dispatch. Actual usage determines the charge. Uncertain outcomes retain a visible reservation for review.
stream = client.chat.completions.create(
model="abliterated-model-large",
messages=[{"role": "user", "content": "Hello!"}],
max_tokens=1024,
stream=True,
stream_options={"include_usage": True}
)
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="")
if chunk.usage:
print("\nUsage:", chunk.usage)Send a unique Idempotency-Key with paid POST requests. Reusing it returns 409 and the original request_id. Check usage history before retrying an interrupted stream.