Summary
This AI domain name generator tutorial shows you how to pair an LLM with the name.com API in Python, filtering AI generated domain candidates down to real, registerable options before you ever open a browser to check them.
Most AI domain name generators are glorified brainstorming tools. They call an LLM, return a plausible-sounding list of names, and leave you to open a browser and check each one manually. That last step is the whole problem. The LLM has no idea what's currently registered. brilliantapp.com looks like a great option until you look it up, and usually it isn't available. You're left with a list of ideas, not a list of options.
The gap matters most when you're building domain search into a product. If you're adding domain registration to a SaaS platform, an internal tool, or an agent workflow, "check availability separately" isn't a pipeline. It's a step the user still has to do by hand. That defeats the purpose entirely.
The fix is straightforward: use the LLM for creative candidate generation and wire it directly to a real domain availability API so that only valid, registrable names reach the user. This tutorial builds that pipeline end-to-end in Python using the name.com Core API, which exposes [POST /core/v1/domains:search](https://docs.name.com/api/v1/reference/domains/search#search) for keyword-based exploration, [POST /core/v1/domains:checkAvailability](https://docs.name.com/api/v1/reference/domains/check-availability) for confirming specific names, and a registration endpoint when you're ready to take the flow all the way through to purchase.
Architecture: two components, one pipeline
The design is intentionally minimal. Stage one: prompt an LLM with a business description and get back a structured list of domain name candidates. This list doesn’t include TLD extensions, just the base names. Stage two: pass those candidates to the API across your target TLDs, filter to what's actually registerable, and return clean results. Optional stage three: register a confirmed-available domain programmatically without leaving your application.
The LLM is creative but uninformed about the registered state of a domain, while our API is authoritative on availability. Each component does exactly one job.
The two availability endpoints serve different purposes, and it's worth clearing up which one you need at which time. A POST call to /core/v1/domains:search takes a keyword and uses name.com's proprietary Domain Engine to return suggested names across different TLDs. This is useful for supplementing LLM output or for building a search box that operates independently. A POST call to /core/v1/domains:checkAvailability takes a list of up to 50 specific domain names (e.g., ["quickinvoice.com", "quickinvoice.io"]) and returns availability and pricing for each. For the pipeline in this tutorial, :checkAvailability is the primary workhorse. You're confirming the LLM's specific suggestions, not asking the API to brainstorm on its own.
Both endpoints include a purchaseType field in the response. Filter to purchaseType == "registration" to exclude aftermarket domains (expired names resold through brokers) and only return domain names that are available for purchase right now. You want names your users can buy at standard registry pricing right now.
Setup: credentials, environments, and authentication
Before writing any code, create a name.com account and navigate to API → API Token Management. Generate two tokens: one for the sandbox environment and one for production. These are separate credentials, not the same token used against different base URLs.
The sandbox environment lives at https://api.dev.name.com and is completely API-only. There's no browser interface, and the data is entirely separate from production. Any domains you register or DNS records you create in the sandbox exist only in that environment. Which is exactly what you want when testing a registration pipeline without suffering real charges on your credit card.
Two things to keep in mind with regards to authentication:
The sandbox username suffix. To authenticate against the sandbox, append -test to your account username. If your account is acmecorp, the sandbox credential username is acmecorp-test. The standard username against the sandbox URL returns an authentication error with no indication of what's wrong.
The 2FA toggle. If two-factor authentication is enabled on your account, API calls fail by default. Go to Account Settings → Security and toggle "name.com API Access" on explicitly. This isn't enabled automatically when you enable 2FA, and the resulting error looks identical to an invalid credential error.
Authentication is HTTP Basic Auth throughout. The username and API token are passed as the auth tuple. Here's the Python setup that handles the sandbox/production switch via environment variable.
First, you need a .env file to store your environment variables. Never hardcode these variables into your main Python script, and never commit .env files to a code repository.
NAMECOM_USERNAME=youruser@yourcorp-test
NAMECOM_API_TOKEN=fe4027eb14593f74a36d5fc9c059ad0ee5b3694a
NAMECOM_API_URL=https://api.dev.name.com # switch to api.name.com/ for productionThen in your main Python script:
import os
import requests
import time
from dotenv import load_dotenv
load_dotenv()
# Read environment variables from .env file
BASE_URL = os.getenv("NAMECOM_API_URL")
USERNAME = os.getenv("NAMECOM_USERNAME")
TOKEN = os.getenv("NAMECOM_API_TOKEN")
# Create the AUTH tuple
AUTH = (USERNAME, TOKEN)When you’ve done all your testing and you want to switch to production, you just edit the .env file and change over to the right username and token combination. You also need to edit “NAMECOM_API_URL” to point to the production environment.
Note that this tutorial does not cover Python basics, like creating virtual environments and installing the necessary Python modules. There are some tutorials available online that cover those topics in more detail.
Generating domain name candidates with an LLM
Getting the prompt right matters more than your choice of model. An unstructured prompt returns a mix of bullet points, prose explanations, and names in various formats. Parsing that downstream requires regex or heuristics that break the moment the model's output style changes. Requesting a JSON array eliminates the problem at the source.
Here's the generation function using the OpenAI Python SDK:
# add these to your import statements at the top
import json
from openai import OpenAI
# initialize the client somewhere after the import
openai_client = OpenAI()
# function that will generate candidates for domain names
def generate_domain_candidates(business_description: str, count: int = 20) -> list[str]:
"""Generate domain name candidates using an LLM. Returns base names without TLD."""
prompt = f"""Generate {count} domain name ideas for the following business:
{business_description}
Return ONLY a JSON array of strings. Each string should be a base domain name WITHOUT the TLD extension.
No explanations, no markdown, no other text — just the JSON array.
Example format: ["quickinvoice", "payslip", "invoicedash", "billtrack"]
Requirements for each name:
- Short (ideally one or two words, or a compact compound word)
- Memorable and brandable
- Directly relevant to the business description
- Suitable for .com, .io, or .co registration"""
response = openai_client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": prompt}],
response_format={"type": "json_object"},
temperature=0.8,
)
result = json.loads(response.choices[0].message.content)
# Handle {"names": [...]} or {"domains": [...]} wrapping
if isinstance(result, list):
return result
for value in result.values():
if isinstance(value, list):
return value
return []Setting response_format={"type": "json_object"} forces GPT-4o to return valid JSON only. No stray markdown, no explanatory text, no malformed output. The prompt explicitly asks for base names without TLD extensions because you want to test each name against multiple TLDs downstream. A single "quickinvoice" becomes "quickinvoice.com", "quickinvoice.io", and "quickinvoice.co" in the next stage.
Temperature at 0.8 is intentional. Lower temperatures produce more predictable but blander results: common words recombined in obvious ways. The availability filter handles output quality on the back end, so erring toward creativity in the LLM stage costs you nothing.
If you're using Anthropic's Claude or another provider, the structure is identical: same prompt, parse the response as JSON. The specific model doesn't matter. What matters is a clean list of strings, because that list feeds directly into the availability check with no intermediate processing step.
Also, remember to update your .env file to include your OpenAI API key (or Anthropic API key if you prefer that platform):
NAMECOM_USERNAME=youruser@yourcorp-test
NAMECOM_API_TOKEN=fe4027eb14593f74a36d5fc9c059ad0ee5b3694a
NAMECOM_API_URL=https://api.dev.name.com # switch to api.name.com/ for production
OPENAI_API_KEY=sk-random-string-you-need-to-replace-with-your-actual-keyChecking domain availability with :search and :checkAvailability
With a list of candidate base names, you're ready to find out which ones are actually registerable. The POST /core/v1/domains:checkAvailability endpoint accepts up to 50 full domain names per request and returns availability status and pricing for each.
One gotcha worth flagging: do not URL-encode the colon in these endpoint paths. The correct path is /core/v1/domains:checkAvailability not /core/v1/domains%3AcheckAvailability. Some URL-building libraries encode colons in path segments. If you're doing anything beyond straightforward string concatenation to build your request URL, verify the final URL in your HTTP client's debug output before assuming the problem is credentials or auth.
Here's the availability check function, which batches the LLM candidates across your target TLDs and handles the 50-domain limit automatically:
# function to check domain availability against the name.com API
def check_domain_availability(
base_names: list[str],
tlds: list[str] = None
) -> list[dict]:
"""
Check availability for base names across specified TLDs.
Handles batching for the 50-domain-per-call limit.
"""
if tlds is None:
tlds = ["com", "io", "co"]
# "quickinvoice" -> ["quickinvoice.com", "quickinvoice.io", "quickinvoice.co"]
full_domains = [f"{name}.{tld}" for name in base_names for tld in tlds]
results = []
for i in range(0, len(full_domains), 50):
batch = full_domains[i:i + 50]
response = make_api_request(
"POST",
f"{BASE_URL}/core/v1/domains:checkAvailability",
json={"domainNames": batch}
)
if response:
results.extend(response.get("results", []))
return resultsThe :search endpoint serves a different purpose. Use it when you want the API's Domain Engine to generate suggestions from a keyword rather than confirming specific names:
# function for searching domains by keyword
def search_domains_by_keyword(keyword: str, timeout_ms: int = 5000) -> list[dict]:
"""
Search for domain suggestions by keyword.
timeout_ms: valid range is 500–12000 (default 12000).
"""
response = make_api_request(
"POST",
f"{BASE_URL}/core/v1/domains:search",
json={"keyword": keyword, "timeout": timeout_ms}
)
return response.get("results", []) if response else []The timeout parameter tells the registry search how long to run. The valid range is 500ms to 12,000ms, with a default of 12,000ms. A 5,000ms timeout is a reasonable starting point: it captures most available results without blocking your response for 12 seconds on every search.
Rate limits, error handling, and filtering available domains
The CORE v1 API enforces two limits: 20 requests per second and 3,000 requests per hour. Breach either and you get HTTP 429. Errors across all endpoints return the same structure: {"message": "...", "details": "..."}.
The make_api_request helper below handles authentication, error logging, and exponential backoff on 429 responses. Define it once; every endpoint call goes through it:
# main helper function to make API requests, including exponential backoff logic
def make_api_request(
method: str,
url: str,
max_retries: int = 3,
**kwargs
) -> dict | None:
"""Authenticated request with retry-on-429 exponential backoff."""
for attempt in range(max_retries):
resp = requests.request(
method,
url,
auth=AUTH,
headers={"Content-Type": "application/json"},
**kwargs
)
if resp.status_code == 429:
wait = 2 ** attempt # 1s, 2s, 4s
print(f"Rate limited. Retrying in {wait}s (attempt {attempt + 1}/{max_retries})...")
time.sleep(wait)
continue
if not resp.ok:
try:
error = resp.json()
print(f"API error {resp.status_code}: {error.get('message')} — {error.get('details', 'no details')}")
except Exception:
print(f"API error {resp.status_code}: {resp.text}")
return None
return resp.json()
print("Max retries exceeded after rate limiting.")
return NoneThe backoff sequence (1s, 2s, 4s) handles short burst scenarios where a single retry clears the limit window. For high-volume pipelines that process hundreds of candidates at once, add a per-second throttle in addition to the backoff. Track the last N request timestamps and insert a small sleep before requests that would push you past 20/second.
Now the filter. The raw API response includes every domain you queried, whether available or not. You want only what's immediately registerable at standard pricing:
# filter only for domains available for purchase, right now
def filter_available_domains(api_results: list[dict]) -> list[dict]:
"""
Return only domains that are available for standard registration.
Excludes aftermarket listings and unavailable domains.
"""
available = []
for result in api_results:
if (
result.get("purchaseType") == "registration"
and result.get("purchasable") is True
):
available.append({
"domain": result.get("domainName"),
"price": result.get("purchasePrice"),
"currency": result.get("purchaseCurrency", "USD"),
})
return availableThe purchaseType == "registration" check is the critical filter. A result with purchaseType == "aftermarket" means the name is technically available but listed through a broker, with unpredictable pricing, manual fulfillment, and no instant registration. Those results look like available domains in the raw response, but they're not what your users want.
Here's the full pipeline assembled:
# function encompassing all the other functions
def generate_available_domains(business_description: str) -> list[dict]:
"""LLM candidates → availability check → filtered registerable domains."""
print("Generating domain name candidates...")
candidates = generate_domain_candidates(business_description, count=20)
print(f"Generated {len(candidates)} candidates. Checking availability across 3 TLDs...")
raw_results = check_domain_availability(candidates, tlds=["com", "io", "co"])
available = filter_available_domains(raw_results)
print(f"Found {len(available)} registerable domains.")
return available
# Run it
results = generate_available_domains(
"A SaaS tool for freelancers to send invoices and track payments"
)
for domain in results:
print(f"{domain['domain']} — ${domain['price']:.2f} {domain['currency']}")A 20-candidate list against 3 TLDs sends 60 domain names to the API in two batches, since the limit per call is 50. Typical LLM output for a well-described business concept yields 8–15 available .io or .co registrations and 2–5 available .com names, depending on how competitive the niche is.
Typical output might look like this:
Generating domain name candidates...
Generated 20 candidates. Checking availability across 3 TLDs...
Found 52 registerable domains.
freelanceinvoice.com — $12.99 USD
freelanceinvoice.io — $53.99 USD
freelanceinvoice.co — $39.99 USD
…
paypath.io — $53.99 USD
paypath.co — $39.99 USD
swiftinvoice.com — $12.99 USD
swiftinvoice.io — $53.99 USD
swiftinvoice.co — $39.99 USD
cashcraft.co — $39.99 USDClosing the loop: programmatic domain registration
Search and filter gets you a list of available domains. Registration takes the pipeline the rest of the way. [POST /core/v1/domains/create-domain](https://docs.name.com/api/v1/reference/domains/create-domain#create-domain) registers a confirmed-available domain programmatically, with no manual browser step required.
# function for registering a domain at domain.com
def register_domain(domain_name: str, contact_info: dict) -> dict | None:
"""
Register a domain. contact_info must match the name.com registrant contact schema.
Test this against the sandbox first — registrations in api.dev.name.com are free and non-binding.
"""
payload = {
"domain": {
"domainName": domain_name,
"contacts": contact_info,
},
"privacyEnabled": True,
}
result = make_api_request(
"POST",
f"{BASE_URL}/core/v1/domains/create-domain",
json=payload
)
if result:
print(f"Successfully registered: {domain_name}")
return resultYou can then run this function to register a domain, like this:
contact_info = {
"tech": {
"firstName": "Jonny",
"lastName": "IT Guy",
"companyName": "My Company",
"address1": "1234 Any Street",
"address2": None,
"city": "Anytown",
"state": "NY",
"zip": "11222",
"country": "US",
"email": "support@example.com",
"phone": "+15555555"
}
}
result = register_domain("paypath.io", contact_info)Run this against the sandbox first. The sandbox processes registrations without real charges and returns realistic response shapes, so you can verify the full pipeline — generation, availability check, and registration — before touching production credentials.
The contacts field follows our registrant structure: first name, last name, email, address, and phone. Check the Create Domain API reference for the exact field structure before your first production call.
Frequently asked questions
Does this pipeline work with models other than GPT-4o?
Yes. The generation function works with any model that returns valid JSON, including Anthropic Claude, Google Gemini, or any OpenAI-compatible endpoint. The key requirement is a clean list of base name strings as output. The downstream availability check doesn’t care which model produced them.
How many domains will actually be available?
It depends on how competitive the niche is. For a well-described, specific business concept, expect roughly 8–15 available .io or .co registrations and 2–5 available .com names from a 20-candidate list. Highly competitive verticals — finance, productivity, AI — will skew lower on .com availability.
What’s the difference between :search and :checkAvailability?
POST /core/v1/domains:search takes a keyword and has our Domain Engine generate and score suggestions — useful as a standalone search box or to supplement LLM output. POST /core/v1/domains:checkAvailability takes a list of specific domain names you provide and confirms their status. For this pipeline, :checkAvailability is the right tool because the LLM already generated the candidate names.
Can I use this pipeline inside an AI agent?
Yes. The name.com API is built to OpenAPI 3.1 spec with MCP support, so AI agents running on Claude or Cursor can call these domain operations via natural language prompts without additional wrapper code.
Final Thoughts
Go ahead, generate sandbox credentials at API → API Token Management, update your .env file and run generate_available_domains() against a test business description. Verify that the pipeline returns a clean list of registerable domains with prices. Once it does, swapping to production means updating your .env file.
Start building for free. No subscription or usage fees required. Explore the name.com API docs →
