- Introduction
- Installation
- Getting Started
- Client
- Text Generation API
- Image Generation API
- Tor Integration
- Advanced Usage
- Troubleshooting
- API Reference
Nexum is a Python framework providing access to multiple AI services through a unified API. It includes:
- Text Generation API: Create text using various AI models, including Gemini, GPT-4, Llama, and others
- Image Generation API: Create images from text prompts using various diffusion models
- Tor Integration: Optional proxy support for enhanced privacy
Nexum is designed for ease of use while providing access to powerful artificial intelligence capabilities.
pip install nexum
- Python 3.9 or higher
- For Tor integration: running Tor service on your machine
Start by importing the Client class and creating a client instance:
from nexum import Client
# Initialize client
client = Client()
The Client
class is the main entry point for interacting with the Nexum API. It provides access to two main services:
completion
: For text generationdiffusion
: For image generation
from nexum import Client
client = Client()
# Access text generation
completion = client.completion
# Access image generation
diffusion = client.diffusion
The text generation API allows you to create text responses using various AI models.
from nexum import Client
client = Client()
# Create a simple response
messages = [
{"role": "user", "content": "Hello!"}
]
# Using the default model (Gemini-2.0-F-Thinking)
response = client.completion.create(messages)
print(response)
# Using a specific model by ID
response = client.completion.create(messages, model=4) # Uses GPT-4o
print(response)
# Using a specific model by name
response = client.completion.create(messages, model="Llama-3.3")
print(response)
# Check which model is being used
response = client.completion.create(messages, model_check=True)
print(response)
# Using Tor proxy for enhanced privacy
response = client.completion.create(messages, proxy=True)
print(response)
Nexum provides access to a variety of text generation models from different providers:
- Gemini-2.0-F-Thinking (ID: 1): Deep context understanding, generating meaningful responses
- Gemini-2.0-Flash (ID: 2): High-speed text generation with excellent context understanding
- Gemini-1.5-Flash (ID: 3): Fast and efficient text generation with good understanding of user queries
- GPT-4o (ID: 4): Multimodal model supporting more than 50 languages with improved context understanding
- O1-Mini (ID: 5): Optimized for STEM tasks, especially mathematics and programming
- Deepseek-R1-Distill (ID: 6): Compact models for reasoning and programming tasks
- Llama-3.3 (ID: 7): Advanced language model with 70 billion parameters
- Llama-3.1 (ID: 8): Large language model with 405 billion parameters and context up to 128k tokens
- Qwen2.5 (ID: 9): Model with 72.7 billion parameters and context up to 128k tokens, improved for coding and mathematics
- Grok-2 (ID: 11): Advanced language model with image generation capabilities
- Grok-Beta (ID: 12): Experimental model with improved reasoning
- ToolBaz-v3.5-Pro (ID: 13): Advanced text generation model
- ToolBaz-v3 (ID: 14): Basic text generation model
- Mixtral (ID: 15): Powerful model with 141 billion parameters using Mixture-of-Experts architecture
- L3-Euryale-v2.1 (ID: 16): Model with 70 billion parameters based on LLaMA-3 architecture
- Midnight-Rose (ID: 17): Unfiltered language model
- Unity (ID: 18): Unfiltered language model
- Unfiltered_X (ID: 19): Unfiltered model with 141 billion parameters
from nexum import Client
from nexum.system.completions.utils.models import Models
# Initialize client
client = Client()
# Create a request with model display
messages = [{'role': 'user', 'content': 'Hello!'}]
response = client.completion.create(messages, model_check=True, model=2)
print(response)
# View all available models
all_models = Models().get_models()
print(all_models)
# Find model by ID
model = Models().get_model_by_id(1)
print(model)
# Find model by name
model = Models().get_model_by_name('Gemini-2.0-F-Thinking')
print(model)
# Universal model search (by ID or name)
model = Models().get_model(1) # By ID
print(model)
model = Models().get_model('Gemini-2.0-F-Thinking') # By name
print(model)
The image generation API allows you to create images from text prompts using various diffusion models.
from nexum import Client
from nexum.system.diffusion.utils.settings import Settings
client = Client()
# Generate image with default settings
prompt = "cute anime cat"
client.diffusion.create(prompt) # Saves to ./media/image.jpg
# Using specific model and save path
client.diffusion.create("beautiful mountain landscape", path="./output/landscape.jpg", model="flux-2")
# Custom settings (only for sdxl-flash model)
settings = Settings(model=2) # Initialize settings for sdxl-flash
settings.set_resolution((768, 512)) # Set custom resolution
settings.set_steps(20) # Set the number of output steps
settings.negative_prompt("blurry, low quality") # Set custom negative prompt
client.diffusion.create(
"cute anime girl",
path="./output/custom_anime.jpg",
settings=settings,
model=2
)
# Using Tor proxy
client.diffusion.create("cute anime cat", path="./output/proxy_cat.jpg", proxy=True)
Nexum currently supports the following image generation models:
-
flux-2 (ID: 1)
- Styles: Realistic and Anime
- NSFW content: Not supported
- Settings: Not customizable
-
sdxl-flash (ID: 2)
- Styles: Realistic and Anime
- NSFW content: Supported
- Settings: Fully customizable
For models that support custom settings (currently only sdxl-flash), you can configure the following parameters:
from nexum.system.diffusion.utils.settings import Settings
settings = Settings(model=2) # Initialize settings for sdxl-flash
# Set custom negative prompt
settings.negative_prompt("low quality, blurry, distorted")
# Set specific seed for reproducible results (or 'random' for random seed)
settings.set_seed(42) # Or settings.set_seed('random')
# Set custom resolution (height, width)
settings.set_resolution((768, 512))
# Set the number of output steps (more = more details but slower)
settings.set_steps(20)
Default settings for sdxl-flash:
- Negative prompt:
(deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation
- Seed: random
- Resolution: 1024x1024
- Steps: 15
from nexum import Client
from nexum.system.diffusion.utils.models import Models
from nexum.system.diffusion.utils.settings import Settings
# Initialize client
client = Client()
# Basic image generation
client.diffusion.create('cute anime cat') # Saves to ./media/image.jpg
# Generation using specific model and save path
client.diffusion.create('cute anime girl', path='./media/girl.png', model=2)
# Generation with custom settings
settings = Settings(model=2)
settings.negative_prompt('(deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy...')
settings.set_seed('random')
settings.set_resolution((1024, 1024))
settings.set_steps(15)
client.diffusion.create(
'cute anime girl',
path='./media/girl_steps_15.png',
model=2,
settings=settings
)
# View all available image generation models
diffusion_models = Models().get_models()
print(diffusion_models)
# Find model by ID or name
model = Models().get_model(1) # By ID
print(model)
model = Models().get_model('flux-2') # By name
print(model)
Nexum provides optional Tor proxy integration for enhanced privacy. This feature requires a running Tor service on your machine.
Add the proxy=True
parameter to any API call:
# Generate text with Tor proxy
response = client.completion.create(messages, proxy=True)
# Generate image with Tor proxy
client.diffusion.create(prompt, path="./output/image.jpg", proxy=True)
from nexum.utils.webtor import Interfice_Tor
# Install Tor if not installed
# Interfice_Tor.install_tor()
# Get a new Tor IP address
Interfice_Tor.new_ip()
# Check your current Tor IP address
current_ip = Interfice_Tor.check_ip()
print(current_ip)
# Complete example using Tor
Interfice_Tor.new_ip()
nexus = Client()
messages = [{'role': 'user', 'content': 'Hello!'}]
print(nexus.completion.create(messages, model_check=True, model=2, proxy=True))
print(nexus.diffusion.create('cute anime cat', proxy=True))
install_tor - works only on Windows, automatic installation on macOS and Linux is not available, but you can download it manually from the official website.
from nexum import Client
client = Client()
messages = [
{"role": "user", "content": "Hi, can you help me with a Python task?"},
{"role": "ai", "content": "Of course! I'd be happy to help with your Python task. What are you working on?"},
{"role": "user", "content": "How do I sort a dictionary by value in Python?"}
]
response = client.completion.create(messages)
print(response)
# Add the response to continue the conversation
messages.append({"role": "ai", "content": response})
messages.append({"role": "user", "content": "Can you show me another example?"})
response = client.completion.create(messages)
print(response)
from nexum.system.completions.utils.models import Models
models = Models()
all_models = models.get_models()
# Output all available models
for provider, provider_models in all_models.items():
print(f"\n{provider} Models:")
for model in provider_models:
print(f" - {model['model_name']} (ID: {model['model_id']})")
if model['description']:
print(f" Description: {model['description']}")
-
Connection Errors
- Ensure your internet connection is stable
- When using Tor, check that the Tor service is running on your machine
-
Model Not Found
- Double-check the model ID or name
- Use the
Models
class to get a list of available models
-
Image Generation Failure
- Ensure the directory for saving images exists or use
os.makedirs()
to create it - Try a different model or a simpler prompt
- Ensure the directory for saving images exists or use
If you encounter issues not described in this documentation, please:
- Check the updated documentation
- Look for similar issues in the project repository
- Submit a detailed bug report with your code and error messages
Client()
Properties:
completion
: Access to the text generation APIdiffusion
: Access to the image generation API
client.completion.create(messages, model=1, model_check=False, proxy=False)
Parameters:
messages
: List of message dictionaries with 'role' and 'content' keysmodel
: Model ID (int) or name (str), default 1 (Gemini-2.0-F-Thinking)model_check
: Whether to include model information in the response, default Falseproxy
: Whether to use Tor proxy, default False
Returns:
- Generated text response as a string
client.diffusion.create(prompt, path='./media/image.jpg', settings=None, model=1, proxy=False)
Parameters:
prompt
: Text prompt for image generationpath
: Output file path, default './media/image.jpg'settings
: Optional Settings object for customizable modelsmodel
: Model ID (int) or name (str), default 1 (flux-2)proxy
: Whether to use Tor proxy, default False
Returns:
- Boolean indicating success or failure
Settings(model=2)
Methods:
negative_prompt(prompt)
: Set negative promptset_seed(seed)
: Set generator seed (int or 'random')set_resolution(res=(height, width))
: Set output resolutionset_steps(steps)
: Set output steps
Property:
setting
: Get current settings dictionary