Features
- Custom AI assistant using Nebius’s LLMs via OpenAI SDK
- Email sending capability using Resend API
- Async/await pattern for efficient execution
- Custom model provider implementation
- Function-based tool creation
Prerequisites
- Python 3.8 or higher
- Nebius API key from Nebius Token Factory
- Resend API key from Resend
- A verified sender email for Resend
Installation
Implementation
Custom Model Provider
Create a custom model provider to use Nebius AI with OpenAI SDK:main.py
Email Tool Implementation
Create a function tool for sending emails:main.py
Agent Execution
main.py
Usage
Run the agent:- Create an assistant that responds in haikus
- Use the email tool to send a test email
- Output the result
Technical Details
Architecture
OpenAI SDK
Agent framework with async support
Nebius AI
LLM provider via OpenAI-compatible API
Resend API
Email sending service integration
Function Tools
Declarative tool definitions
Model Configuration
The agent supports any model from Nebius Token Factory. Configure via environment variables:EXAMPLE_BASE_URL: API endpointEXAMPLE_MODEL_NAME: Model identifier
Customization
Change Assistant Instructions
Add More Tools
Use Different Models
Modify the environment variable or pass directly:Environment Variables
| Variable | Description | Default |
|---|---|---|
NEBIUS_API_KEY | Nebius API key | Required |
RESEND_API_KEY | Resend API key | Required |
EXAMPLE_BASE_URL | Nebius API endpoint | https://api.tokenfactory.nebius.com/v1 |
EXAMPLE_MODEL_NAME | Model to use | meta-llama/Meta-Llama-3.1-8B-Instruct |
Next Steps
MCP Integration
Connect to external services via MCP
Multi-Agent Systems
Build complex agent workflows