diskd-ai

nebius-api

0
0
# Install this skill:
npx skills add diskd-ai/nebius-api

Or install specific skill: npx add-skill https://github.com/diskd-ai/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.

# SKILL.md


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):

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.

# README.md

Nebius Token Factory API Skill

Install: npx skills add diskd-ai/nebius-api | skills.sh

Integration skill for building AI-powered applications with Nebius Token Factory (tokenfactory.nebius.com) and its OpenAI-compatible API.


Scope & Purpose

This skill provides guidance and patterns for working with Nebius Token Factory, covering:

  • OpenAI-compatible inference: chat/completions/embeddings/images
  • Streaming (SSE) and tool/function calling
  • JSON mode / structured outputs
  • Model discovery (GET /v1/models, verbose=true)
  • Files and batch processing
  • Fine-tuning jobs (OpenAI-style)
  • Token Factory extensions: datasets multipart uploads and operations (checkpoints/results)
  • Custom model management (/v0/models)

When to Use This Skill

Triggers:
* Mentions of Nebius Token Factory, tokenfactory.nebius.com, or ai_project_id
* Implementing a Nebius provider adapter/client in TypeScript/JavaScript/Python
* Configuring OpenAI-compatible tooling (OpenAI SDK, LangChain, LiteLLM, etc.) to target Nebius
* Migrating from Nebius AI Studio keys to Token Factory keys/base URL

Use cases:
* Add chat completions via OpenAI SDK with baseURL=https://api.tokenfactory.nebius.com/v1/
* Implement streaming responses and tool calls
* List/choose models dynamically from /v1/models
* Upload files and run batch jobs
* Run fine-tuning jobs and inspect status
* Upload datasets and run/stop operations; inspect checkpoints and results


Quick Reference

Installation

# Python
pip install openai

# TypeScript/JavaScript
npm install openai

Environment

export NEBIUS_API_KEY=<your-api-key>
# Optional: scope requests to a specific project
export NEBIUS_AI_PROJECT_ID=<your-project-id>

Basic Usage

Python (OpenAI SDK):

from openai import OpenAI

client = OpenAI(
    api_key="<NEBIUS_API_KEY>",
    base_url="https://api.tokenfactory.nebius.com/v1/",
)

response = client.chat.completions.create(
    model="your-model-id",
    messages=[{"role": "user", "content": "Hello"}],
)

TypeScript (OpenAI SDK):

import OpenAI from 'openai';

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

const response = await client.chat.completions.create({
  model: 'your-model-id',
  messages: [{ role: 'user', content: 'Hello' }],
});

Model Selection Guide

Availability changes over time; always fetch the canonical list from GET /v1/models (use verbose=true when needed).

Use Case How to Choose Notes
Fast + cheap pick a small instruct/chat model best for simple tasks
Balanced pick a mid/large instruct model quality/cost balance
Highest quality pick the strongest instruct model highest latency/cost
Reasoning pick a reasoning-tuned model may be slower
Code pick a coder model best for coding tasks
Embeddings pick an embedding model for RAG/semantic search
Images pick an image model for image generation

Skill Structure

nebius-api/
  SKILL.md          # Full reference and patterns
  README.md         # This file (overview)
  references/       # Supporting documentation
    basics.md
    endpoints.md
    datasets-and-operations.md
  scripts/
    nebius-smoke-test.mjs

Key Patterns

Project scoping (ai_project_id)

Some workflows require explicit project scoping via ai_project_id. Use request-level query params (SDK) or raw HTTP.

Streaming responses (SSE)

Treat streaming as Server-Sent Events (SSE): parse data: frames and stop on [DONE].

JSON mode / structured outputs

Use OpenAI-style response_format (when supported by the chosen model) to force machine-readable output.


Smoke Test

Run a minimal check against /models and /chat/completions:

NEBIUS_API_KEY=... node scripts/nebius-smoke-test.mjs

Migration note

Nebius AI Studio API keys remain valid only until January 31, 2026. Token Factory uses different keys and base URL.


Resources


License

MIT

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.