io.net 백서

io.net

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 31쪽 중 16쪽

e via API*** When using Portkey programmatically, reference IO Intelligence as an OpenAI-compatible provider: ```json theme={null} { "provider": "iointelligence", "apiKey": "<IO_INTELLIGENCE_API_KEY>" } ``` With this, portkey automatically handles: * Base URL resolution ([https://api.intelligence.io.solutions/api/v1](https://api.intelligence.io.solutions/api/v1)) * Bearer authentication headers * Endpoint mapping for chat completions </Tab> </Tabs> ### Step 2: Make Your First Request Test your integration using the following examples. ***Chat Completion Example:*** ```json theme={null} { "provider": "iointelligence", "model": "meta-llama/Llama-3.3-70B-Instruct", "messages": [ { "role": "user", "content": "Hello!" } ] } ``` ***Expected Response:*** ```json theme={null} { "provider": "iointelligence", "id": "chatcmpl-xyz", "choices": [ { "message": { "role": "assistant", "content": "Hi there!" } } ] } ``` <Note> All responses follow the **OpenAI response schema**, enabling drop-in compatibility with existing tooling. </Note> ## Advanced Configuration ### Using IO Intelligence as Primary with Fallback As a standard Portkey provider, IO Intelligence can be included in routing and fallback configurations together with other providers. All fallback logic is defined and controlled by the Portkey gateway. Portkey can route requests to your chosen fallback provider if the following errors are encountered: * Rate limited (Error 429) * Provider errors (Error 5xx) ## Supported Endpoints | Endpoint | Function Name | Endpoint Path | | :- | :- | :- | | Chat Completions | `chatComplete` | `/chat/completions` | | Create Model Response | `createModelResponse` | `/chat/completions` | <Note> All endpoints are OpenAI-compatible and normalized by Portkey’s response transformers </Note> ## Error Handling The following table shows errors you may encounter: | Status Code | Description | | :- | :- | | 401 | Missing or invalid API key | | 404 | Incorrect endpoint or invalid model | | 422 | Invalid request payload | | 429 | Rate limit exceeded | | 500 | Provider-side error | ### Troubleshooting Checklist * Confirm `.env` variables are loaded. * Verify model names are correct. * Validate request payload structure. * Retry 429 / 500 errors with backoff. * Inspect Portkey gateway logs for normalized requests. # Reasoning for Chat Completions Source: https://io.net/docs/guides/intelligence/reasoning-for-chat-completions IO Intelligence supports models that can "think" before answering — exposing their step-by-step reasoning alongside the final response. You control this behavior with a single, OpenAI-compatible `reasoning` field on every chat completion request. ## Enable or disable reasoning Add a `reasoning` object to your `/v1/chat/completions` payload: ```json theme={null} { "model": "moonshotai/Kimi-K2.6", "messages": [{ "role": "user", "content": "..." }], "reasoning": { "effort": "medium" } } ``` | `effort` value | Behavior | | :- | :- | | `"none"` | **Disable** reasoning | | `"low"` | Enable reasoning, lighter thinking | | `"medium"` | Enable reasoning, balanced thinking | | `"high"` | Enable reasoning, deeper thinking | | *(field omitted)* | Use the model's default behavior | The same field works for every model that supports reasoning — no per-model configuration required. ## Quickstart ### Enable reasoning (curl) ```shellscript theme={null} curl https://api.intelligence.io.solutions/api/v1/chat/completions \ -H "Authorization: Bearer $IO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-ai/DeepSeek-V4-Pro", "messages": [ { "role": "user", "content": "A farmer has 30 heads and 74 legs across his chickens and cows. How many of each?" } ], "reasoning": { "effort": "medium" } }' ``` ### Disable reasoning (curl) ```shellscript theme={null} curl https://api.intelligence.io.solutions/api/v1/chat/completions \ -H "Authorization: Bearer $IO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "moonshotai/Kimi-K2.6", "messages": [ { "role": "user", "content": "Just give me the number: what is 7 + 9?" } ], "reasoning": { "effort": "none" } }' ``` ### Python (OpenAI SDK) ```python theme={null} from openai import OpenAI client = OpenAI( base_url="https://api.intelligence.io.solutions/api/v1", api_key="YOUR_IO_API_KEY", ) # Enable reasoning response = client.chat.completions.create( model="moonshotai/Kimi-K2.6", messages=[{"role": "user", "content": "Plan a 3-day Lisbon itinerary."}], extra_body={"reasoning": {"effort": "medium"}}, ) # Disable reasoning response = client.chat.completions.create( model="moonshotai/Kimi-K2.6", messages=[{"role": "user", "content": "What is 7 + 9? Just the number."}], extra_body={"reasoning": {"effort": "none"}}, ) ``` ### Node.js (OpenAI SDK) ```javascript theme={null} import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.intelligence.io.solutions/api/v1", apiKey: process.env.IO_API_KEY, }); const response = await client.chat.completions.create({ model: "moonshotai/Kimi-K2.6", messages: [{ role: "user", content: "Plan a 3-day Lisbon itinerary." }], // @ts-expect-error — reasoning is an IO Intelligence extension reasoning: { effort: "medium" }, }); ``` ## Reading the response When reasoning is **enabled**, the model's chain of thought is returned in `choices[0].message.reasoning_content`, and reasoning tokens are reported in `usage.completion_tokens_details.reasoning_tokens`: ```json theme={null} { "choices": [ { "message": { "role": "assistant", "reasoning_content": "Let me set up two equations: c + w = 30 and 2c + 4w = 74...", "content": "23 chickens and 7 cows." } } ], "usage": { "completion_tokens": 65, "completion_tokens_details": { "reasoning_tokens": 48 } } } ``` When reasoning is **disabled** (`"effort": "none"`): * `reasoning_content` is `null` or omitted * `reasoning_tokens` is `0` (or near-zero for models that always think internally) * The visible answer is in `content` only ## Streaming Reasoning works with `"stream": true` as well. While the model is thinking, you'll receive delta events with a `reasoning_content` field; once thinking finishes, regular `content` deltas follow. ```json theme={null} { "choices": [{ "delta": { "reasoning_content": "Let me set up..." } }] } { "choices": [{ "delta": { "reasoning_content": " two equations..." } }] } { "choices": [{ "delta": { "content": "23 chickens" } }] } { "choices": [{ "delta": { "content": " and 7 cows." } }] } ``` ## Backwards compatibility * Requests **without** the `reasoning` field continue to behave exactly as before. * The legacy `reasoning_effort: "low" | "medium" | "high"` top-level string is still accepted.\ You can safely roll out the new field at your own pace. ## Errors | Status | Meaning | | :- | :- | | 400 | A small number of always-reasoning models reject `effort: "none"`. Use a different effort or omit the field. | | 402 | The selected model requires a higher IO Intelligence tier. | | 429 | You've been rate-limited. Back off and retry. | ## Models Enabled The capability of reason enabling/disabling has been enabled for the following models: | Model | Enable | Disable | Notes | | :- | :- | :- | :- | | `moonshotai/Kimi-K2.6` | ✓ | ✓ | Clean toggle | | `openai/gpt-oss-120b` | ✓ | ✓ | Always reasons internally; `effort:"none"` suppresses `reasoning_content` only | | `deepseek-ai/DeepSeek-V4-Pro` | ✓ | ✓ | Clean toggle | | `deepseek-ai/DeepSeek-V4-Flash` | ✓ | ✓ | | | `deepseek-ai/DeepSeek-V3.2` | ✓ | ✓ | Doesn't always engage reasoning for trivial prompts | | `MiniMaxAI/MiniMax-M2.7` | ✓ | N/A | Always-on reasoning by design, `effort:"none"` is a no-op for this model | | `google/gemma-4-26b-a4b-it` | — | — | Reasoning routing in progress; check release notes before relying on it | ## FAQs <AccordionGroup> <Accordion title="Do I need different code for different models?" icon="comment-question"> No. Use `reasoning.effort` everywhere, IO Intelligence handles the rest. </Accordion> <Accordion title="What does each effort level cost me in tokens?" icon="comment-question"> Reasoning tokens are billed as completion tokens. none skips them entirely; low/medium/high each produce progressively more reasoning tokens. Exact budgets vary by model. </Accordion> <Accordion title="Can I hide the chain of thought from end users while still using it internally?" icon="comment-question"> Yes, just don't render `reasoning_content` in your UI. It's returned as a separate field so you can choose whether to show it. </Accordion> <Accordion title="Does this work with tool calls / function calling?" icon="comment-question"> Yes. Reasoning happens before tool selection; the chain of thought explains *why* the model chose a particular tool call. </Accordion> </AccordionGroup> # Sub-API Keys Source: https://io.net/docs/guides/intelligence/sub-api-keys Issue scoped API keys to teams, services, or partners — each with independent model restrictions and credit limits that roll up to your account balance. Sub-API keys allow an account holder (the *admin*) to issue multiple child API keys, each independently controlled. Each sub-key can be restricted to specific models, given a spending cap per billing cycle, and revoked at any time — without touching the admin key or other sub-keys. ## Overview When you create a sub-key: * It inherits your account's credit pool — there is no separate balance to fund. * You optionally cap how much of that pool any single sub-key can consume per billing period. * You optionally restrict which models the sub-key can call. * The sub-key's usage feeds back into your account's overall billing. This is useful for: * **Teams** — give each team or project its own key with a monthly budget. * **Partners / customers** — provide programmatic API access with hard credit limits so a single integration can never exhaust your entire balance. * **Services** — isolate microservices with model allow-lists so they can only call the models they need. ## Authentication All sub-key management endpoints use your **admin API key** in the `x-api-key` header. Sub-keys themselves authenticate inference calls (chat completions, embeddings, etc.) using the same header — they are recognized automatically by the API. ```bash theme={null} # Admin operations (create, list, update, revoke) -H "x-api-key: $ADMIN_API_KEY" # Inference calls using a sub-key -H "x-api-key: $SUB_API_KEY" ``` <Note> Sub-keys cannot create further sub-keys. Only an admin key can manage the key hierarchy. </Note> ## Creating a Sub-API Key <Steps> <Step title="Call the create endpoint with your admin key"> ```bash theme={null} curl -X POST "https://api.io.solutions/v1/api-keys/sub-keys" \ -H "x-api-key: $ADMIN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "description": "Partner integration – Acme Corp", "allowed_models": ["meta-llama/Llama-3.3-70B-Instruct"], "credit_limit": 10.0, "credit_refresh_cycle": "monthly", "key_prefix": "acme" }' ``` </Step> <Step title="Store the returned key value securely"> The response includes a `value` field with the full key string (e.g. `acme-v2-eyJhbGci...`). This is shown **only once**. Copy it to a secret manager immediately — it cannot be retrieved again. ```json theme={null} { "status": "succeeded", "data": { "key_id": "71775d2e-fbcc-4ef4-aa30-8aaeb82062c0", "value": "acme-v2-eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...", "display": "acme-v2-eyJh...c0eQ", "description": "Partner integration – Acme Corp", "allowed_models": ["meta-llama/Llama-3.3-70B-Instruct"], "credit_limit": 10.0, "credit_refresh_cycle": "monthly", "expires_at": "2026-08-20T00:00:00" } } ``` </Step> <Step title="Distribute the sub-key to its intended user or service"> The recipient uses the sub-key exactly like a regular API key — just pass it in the `x-api-key` header for inference calls. </Step> </Steps> ## Request Parameters | Field | Type | Required | Description | | - | - | - | - | | `description` | string | Yes | Human-readable label for the key. | | `allowed_models` | string\[] | No | List of model IDs this key may call. Omit to allow all models. | | `credit_limit` | number | No | Maximum credits per refresh cycle. Omit for no per-key cap. | | `credit_refresh_cycle` | string | No | When the usage counter resets: `"8h"`, `"daily"`, `"weekly"`, `"monthly"` (default). | | `expires_at` | datetime / `"never"` | No | Key expiry. Defaults to 180 days from creation. | | `key_prefix` | string | No | 2–8 char lowercase slug prepended to the key (e.g. `"acme"` → `acme-v2-...`). Defaults to the standard `io-v2` prefix. | ## Model Restrictions When `allowed_models` is set, any request to a model not in the list is rejected with **403 Forbidden**, even if the admin key has access to that model. The `GET /v1/models` endpoint, when called with a sub-key, returns only the models in the sub-key's allow-list — so integrations can discover their permitted set without any extra configuration. To remove all restrictions on an existing sub-key, pass an empty array: ```bash theme={null} curl -X PATCH "https://api.io.solutions/v1/api-keys/sub-keys/{key_id}" \ -H "x-api-key: $ADMIN_API_KEY" \ -H "Content-Type: application/json" \ -d '{"allowed_models": []}' ``` ## Credit Limits ### How limits are enforced Credit limits are evaluated once per billing cycle by the settlement pipeline (which runs every \~60 seconds). When a sub-key's accumulated spend in the current period exceeds its `credit_limit`, the key is automatically blocked and inference calls return **429 Too Many Requests**. The block clears automatically when the cycle resets (`credit_refresh_cycle`), or immediately when you raise the limit via `PATCH`. ### Blocking and unblocking <AccordionGroup> <Accordion title="A sub-key is returning 429 — how do I unblock it?"> The key has exceeded its `credit_limit` for the current period. You have two options: **Raise the limit immediately:** ```bash theme={null} curl -X PATCH "https://api.io.solutions/v1/api-keys/sub-keys/{key_id}" \ -H "x-api-key: $ADMIN_API_KEY" \ -H "Content-Type: application/json" \ -d '{"credit_limit": 50.0}' ``` **Wait for the next cycle reset** — the key unblocks automatically when `credit_refresh_cycle` rolls over. </Accordion> <Accordion title="How do I check how much a sub-key has spent?"> Use the admin endpoint to inspect a specific key: ```bash theme={null} curl "https://api.io.solutions/v1/api-keys/sub-keys/{key_id}/usage" \ -H "x-api-key: $ADMIN_API_KEY" ``` Or let the sub-key check itself: ```bash theme={null} curl "https://api.io.solutions/v1/api-keys/sub-keys/me/usage" \ -H "x-api-key: $SUB_API_KEY" ``` </Accordion> <Accordion title="What happens to my account balance when a sub-key is blocked?"> The block applies only to that specific sub-key. Your admin key and all other sub-keys continue operating normally. The admin's overall account balance is not affected by per-key limits. </Accordion> </AccordionGroup> ## Credit Refresh Cycles The `credit_refresh_cycle` determines when a sub-key's `credit_used` counter resets to zero, allowing spending up to `credit_limit` again. | Cycle | Resets at | | - | - | | `8h` | Every 8 hours aligned to midnight UTC (00:00, 08:00, 16:00). | | `daily` | Midnight UTC each day. | | `weekly` | Monday 00:00 UTC. | | `monthly` | The 1st of each month at 00:00 UTC. | ## Custom Key Prefix By default, sub-keys follow the standard `io-v2-` format. You can supply a custom `key_prefix` to make keys visually identifiable: ```json theme={null} { "key_prefix": "acme" } ``` Produces: `acme-v2-eyJhbGci...` **Prefix rules:** * 2–8 characters, lowercase letters, digits, and internal hyphens only. * Cannot start with `io` (reserved for platform keys). * Cannot contain version markers like `-v2`. The prefix does not change any functionality — it is purely cosmetic for organizational clarity. ## Managing Sub-Keys ### Listing keys ```bash theme={null} curl "https://api.io.solutions/v1/api-keys/sub-keys" \ -H "x-api-key: $ADMIN_API_KEY" ``` Returns all active sub-keys with their current `credit_used` for the active billing period. ### Updating a key All fields on a sub-key can be updated at any time. Only the fields you include in the `PATCH` body are changed: ```bash theme={null} curl -X PATCH "https://api.io.solutions/v1/api-keys/sub-keys/{key_id}" \ -H "x-api-key: $ADMIN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "description": "Updated label", "credit_limit": 25.0, "credit_refresh_cycle": "weekly" }' ``` ### Revoking a key ```bash theme={null} curl -X DELETE "https://api.io.solutions/v1/api-keys/sub-keys/{key_id}" \ -H "x-api-key: $ADMIN_API_KEY" ``` Revocation is immediate and permanent. Any subsequent inference call with the revoked key returns **401 Unauthorized**. ## Viewing Usage ### All sub-keys (admin) ```bash theme={null} curl "https://api.io.solutions/v1/api-keys/sub-keys/usage" \ -H "x-api-key: $ADMIN_API_KEY" ``` Returns a per-key breakdown of token consumption and credit cost, grouped by model, for today and all time — plus aggregate totals across all sub-keys. ### Single sub-key (admin) ```bash theme={null} curl "https://api.io.solutions/v1/api-keys/sub-keys/{key_id}/usage" \ -H "x-api-key: $ADMIN_API_KEY" ``` ### Self-service (sub-key holder) ```bash theme={null} curl "https://api.io.solutions/v1/api-keys/sub-keys/me/usage" \ -H "x-api-key: $SUB_API_KEY" ``` ## FAQs <AccordionGroup> <Accordion title="Do sub-keys have their own credit balance?" icon="comment-question"> No. Sub-keys draw from the admin's account balance. The `credit_limit` is a spending cap per cycle, not a separate balance. All usage by sub-keys is deducted from the same pool as the admin's own usage. </Accordion> <Accordion title="Can a sub-key call any model endpoint?" icon="comment-question"> Only the models listed in `allowed_models`. If no list is configured, the sub-key can call any model available to the admin account. The `/v1/models` endpoint filters its response to only show the permitted models when called with a sub-key. </Accordion> <Accordion title="What happens when the cycle resets?" icon="comment-question"> The sub-key's `credit_used` counter is reset to zero at the start of each new period. If the key was blocked due to exceeding its limit, it is automatically unblocked. </Accordion> <Accordion title="How quickly does blocking take effect after the limit is exceeded?" icon="comment-question"> The billing settlement pipeline runs approximately every 60 seconds. Once a sub-key's accumulated spend exceeds its `credit_limit`, the block is applied within the next pipeline run. </Accordion> <Accordion title="Can I have sub-keys without a credit limit?" icon="comment-question"> Yes. Omit `credit_limit` (or set it to `null`) when creating or updating a sub-key. The key will only be limited by the admin's overall account balance. </Accordion> <Accordion title="Is the key prefix stored anywhere?" icon="comment-question"> No. The prefix is encoded in the key string itself. The display value (e.g. `acme-v2-eyJh...c0eQ`) shows the prefix so you can identify it, but it is not stored separately in the database. </Accordion> </AccordionGroup> # Training as a Service (TaaS) Source: https://io.net/docs/guides/intelligence/training-as-a-service Customize and fine-tune models to fit your needs - no need to train from scratch. <Info> Note: This feature is currently in Beta. We are actively refining the experience and would love to hear your feedback. </Info> With IO Intelligence’s [Training as a Service (TaaS)](https://ai.io.net/ai/training), you can fine-tune powerful pre-trained models using your own data—achieving tailored performance without the complexity of training from scratch. Built for
프로젝트로 돌아가기