Namegiver: AI-based Character Name Generator
A lightweight, OpenAI-powered Python library for generating unique fictional character names based on user-provided prompts. Designed for writers, game developers, and world-builders.
Features
AI-Generated Names – Distinctive names based on user descriptions.
Ensures Name Distinctiveness – Avoids generating names too similar to previous ones.
Supports CLI & API – Use from the terminal or integrate into Python projects.
Economy Mode – Uses GPT-3.5 by default; switch to GPT-4 if needed.
Token Usage Tracking – Monitor OpenAI API token consumption.
Installation
1. Install via pip
pip install namegiver
This will install the package and all its dependencies.
2. Set Up API Key
Create a .env file in your project directory:
OPENAI_API_KEY=your-api-key-here
ECONOMY_MODE=True
Alternatively, set it in your shell:
export OPENAI_API_KEY="your-api-key-here"
export ECONOMY_MODE="True"
Usage
1. Using the Python API
from namegiver import generate_unique_name, get_token_usage
past_names = ["Elwin", "Alvin", "Elvin"]
# Generate a unique name while avoiding past names
print(generate_unique_name("sci-fi bounty hunter", past_names))
# Show token usage
print("Token Usage Report:", get_token_usage())
2. Using the CLI
Generate a Name
namegen "medieval knight"
Example Output:
Sir Aldrin of Westmere
Specify Maximum Token Length
namegen "steampunk engineer" --max-tokens 5
Example Output:
Brasswick
Avoid Similar Names
namegen "elf warrior" --past-names Legolas Thranduil Elrond
Example Output:
Faerion
Check Token Usage
namegen --report
Example Output:
Token Usage Report: {'total_tokens_used': 50}
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
| OPENAI_API_KEY | (Required) | Your OpenAI API key |
| ECONOMY_MODE | True | If True, uses gpt-3.5-turbo. Set to False for GPT-4 |
How It Works
- The library queries OpenAI's LLM to generate a name.
- If
past_namesis provided, it asks OpenAI to avoid those names. - After generation, the name is checked using Levenshtein distance to prevent near-duplicates.
- If the generated name is too similar, the system regenerates up to 5 times.
Development
Run Locally
Clone the repo and install dependencies:
git clone https://github.com/yourusername/namegiver.git
cd namegiver
pip install -e .
Run Tests
Run the test suite with:
pytest tests/
Contributing
Contributions are welcome! Submit issues or pull requests.
License
This project is licensed under the MIT License.
Metadata
Release files for namegiver 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| namegiver-0.1.4.tar.gz | 6.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| namegiver-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.3 kB
Release files / namegiver-0.1.4.tar.gz
| Download URL | namegiver-0.1.4.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d79ffe8b79faeaad7590eb3998472b9e1316db59f3932c6084ddf7ee01dab1f3
|
|
BLAKE2b-256 checksum How to use checksums |
3ecc65a37e3eb4359d7ce438fb8338d5b1f69546156ae11d82be76d08621f6fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / namegiver-0.1.4-py3-none-any.whl
| Download URL | namegiver-0.1.4-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89726dd0a132a72a0e1d7865622d94f158be409c13685916c32161b8ab06919f
|
|
BLAKE2b-256 checksum How to use checksums |
9d5fa544760f66853567b0f93a71f5f95621484ea19e35e7347de0cf9a874665
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|