AgentSkillsCN

nebius-api

在 TypeScript/JavaScript/Python 中集成 Nebius Token Factory(tokenfactory.nebius.com)的 OpenAI 兼容 API,包括认证与基础 URL 配置、聊天/补全/嵌入/图像功能、模型发现、批量处理、文件操作、微调、自定义模型,以及数据集与各类操作。当您在 TypeScript/JavaScript/Python 中新增 Nebius 提供商适配器或客户端,或在配置 OpenAI 兼容工具链(OpenAI SDK、LangChain、LiteLLM 等)以对接 Nebius 时使用此技能。

SKILL.md
--- frontmatter
name: nebius-api
description: Implement and maintain integrations with Nebius Token Factory (tokenfactory.nebius.com) OpenAI-compatible API, including auth + base URL config, chat/completions/embeddings/images, model discovery, batch, files, fine-tuning, custom models, and datasets/operations. Use when adding a Nebius provider adapter/client in TypeScript/JavaScript/Python or configuring OpenAI-compatible tooling (OpenAI SDK, LangChain, LiteLLM, etc.) to target Nebius.

Nebius API (Token Factory)

Overview

Use Nebius Token Factory’s OpenAI-compatible API for inference and post-training: chat/completions/embeddings/images, model listing, batch, files, fine-tuning, custom models, and datasets/operations.

Quick Start (OpenAI-compatible)

  1. Create an API key in the Token Factory console.
  2. Use base URL https://api.tokenfactory.nebius.com/v1/.
  3. Send OpenAI-compatible requests (prefer reusing the OpenAI SDK; fall back to raw HTTP for non-SDK endpoints like datasets/operations).

TypeScript (Node, OpenAI SDK):

ts
import OpenAI from 'openai';

const apiKey = process.env.NEBIUS_API_KEY;
if (!apiKey) throw new Error('NEBIUS_API_KEY is required');

const client = new OpenAI({
  apiKey,
  baseURL: 'https://api.tokenfactory.nebius.com/v1/',
});

const res = await client.chat.completions.create({
  model: 'meta-llama/Meta-Llama-3.1-70B-Instruct',
  messages: [{ role: 'user', content: 'Hello from Nebius' }],
});

console.log(res.choices[0]?.message?.content ?? '');

Capabilities Checklist

Implement these as needed (Nebius is OpenAI-compatible for most of them; some features use additional endpoints):

  • Inference: POST /v1/chat/completions, POST /v1/completions, POST /v1/embeddings, POST /v1/images/generations
  • Models: GET /v1/models (plus verbose), custom models under /v0/models
  • Batch: POST /v1/batches, GET /v1/batches, GET /v1/batches/{id}, POST /v1/batches/{id}/cancel
  • Files: POST /v1/files, GET /v1/files, GET /v1/files/{id}, DELETE /v1/files/{id}, GET /v1/files/{id}/content
  • Fine-tuning: POST /v1/fine_tuning/jobs, GET /v1/fine_tuning/jobs, GET /v1/fine_tuning/jobs/{id}, POST /v1/fine_tuning/jobs/{id}/cancel
  • Datasets + operations: multipart upload + dataset CRUD + run/stop operations and inspect checkpoints

Guidance

  • Prefer a small provider adapter layer: explicit config (base URL, API key, optional ai_project_id), typed errors, and pure helper functions for request shaping.
  • Treat streaming as SSE: parse data: frames; terminate on [DONE].
  • Use ai_project_id query param when your auth model requires scoping requests to a specific project.

References

  • Read references/basics.md for auth, base URL, ai_project_id, and key migration notes.
  • Read references/endpoints.md for an endpoint map and implementation notes.
  • Read references/datasets-and-operations.md for dataset uploads + operations workflow.
  • Run scripts/nebius-smoke-test.mjs to validate an API key against /models and /chat/completions.