Api Native

nebius-token-factory-cookbookapi
[ ]

Run models on Nebius Token Factory (Native)

Open In Colab

This the recommended API. The API uses OpenAI library.

References and Acknowledgements

Pre requisites

1 - Install Dependencies

[1]

2 - Load Configuration

[2]
NOT running in Colab
✅ NEBIUS_API_KEY found

3 - Pick a Model

  1. Go to models tab in tokenfactory.nebius.com
  2. Copy the model name. For example openai/gpt-oss-20b-Instruct-2507

4 - Run the Model

[3]
----model answer -----
The capital of France is Paris.

----- full response ----
{
  "id": "chatcmpl-50f7bcb284ed40cbb45d67225acbb97d",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "message": {
        "content": "The capital of France is Paris.",
        "refusal": null,
        "role": "assistant",
        "annotations": null,
        "audio": null,
        "function_call": null,
        "tool_calls": [],
        "reasoning_content": null
      },
      "stop_reason": null,
      "token_ids": null
    }
  ],
  "created": 1762232990,
  "model": "openai/gpt-oss-20b-Instruct-2507",
  "object": "chat.completion",
  "service_tier": null,
  "system_fingerprint": null,
  "usage": {
    "completion_tokens": 8,
    "prompt_tokens": 15,
    "total_tokens": 23,
    "completion_tokens_details": null,
    "prompt_tokens_details": null
  },
  "prompt_logprobs": null,
  "prompt_token_ids": null,
  "kv_transfer_params": null
}
---------
CPU times: user 235 ms, sys: 62.5 ms, total: 298 ms
Wall time: 1.94 s

5 - Try a Reasoning Model

[5]


I'm Qwen3, the latest large language model developed by Tongyi Lab! Here's a quick overview of what I can do for you:

---

### ✨ **Key Capabilities**
1. **Language Understanding & Generation**  
   - Answer questions (e.g., "Explain quantum computing simply")  
   - Summarize long documents or articles  
   - Write stories, emails, scripts, and creative content  
   - *Example:* "Write a 200-word poem about autumn in the style of Shakespeare."

2. **Code Writing & Debugging**  
   - Generate code in **Python, JavaScript, Java, C++, SQL**, and more  
   - Fix errors and optimize existing code  
   - *Example:* "Debug this Python function that’s causing a `KeyError`."

3. **Multilingual Support**  
   - Translate between **100+ languages** (e.g., Chinese ↔ English, Spanish ↔ French)  
   - Understand and respond in your preferred language  
   - *Example:* "Translate this paragraph into Japanese."

4. **Long-Context Processing**  
   - Handle inputs up to **128,000 tokens** (e.g., process a full book or lengthy research paper).

5. **Logical Reasoning & Math**  
   - Solve puzzles, math problems, and logical sequences  
   - *Example:* "Solve this equation: 3x + 5 = 20."

6. **Role-Playing & Creative Tasks**  
   - Simulate characters or scenarios (e.g., "Act as a travel guide for Paris")  
   - Generate business plans, marketing copy, or technical documentation.

---

### 💡 **Why It Matters**
- **No internet access**: I rely on my training data (up to 2024), so I can’t fetch real-time info—but I’m great for *structured* tasks like writing, coding, and analysis.  
- **Efficient & Cost-Effective**: Optimized for speed and affordability, whether you’re a developer, student, or business user.

---

**Try me out!** Ask anything like:  
- "Write a Python script to scrape a website."  
- "Explain blockchain to a 10-year-old."  
- "Help me draft a resignation email."  

Let me know what you’d like to tackle! 😊
----------
CPU times: user 5.25 ms, sys: 2.43 ms, total: 7.68 ms
Wall time: 35.1 s

6 - Try Your Queries

Go ahead and experiment with your queries. Here are some to get you started.

Write python code to read a csv file

write a haiku about cats