Initialize a Project
In shortScaffold a 10xGraph project with interactive prompts or CLI flags, and understand what each setup generates.
- 7 min read
- 11 sections
- Updated
- v1.0.0
- Markdown
10xgraph init scaffolds a new agent project from an interactive questionnaire or command-line flags. It creates a working graph, configuration file, and optional test/evaluation stubs tailored to your deployment model (Quick for development, Full for teams and deployment).
Prerequisites
Install the 10xgraph CLI package:
pip install 10xgraph-apiQuickstart: interactive mode
Navigate to an empty directory and run:
10xgraph initThe command asks three questions: the agent name, the setup and the AI provider. It then prints a summary of what it wrote and creates the files. The Full setup does not ask about auth or rate limiting; it writes the recommended setup (see How 10xgraph.json is generated). The next steps point to 10xgraph config for full control.
To scaffold in a specific directory without entering it:
10xgraph init --path ./my-agent-projectNon-interactive mode: CLI flags
For CI pipelines or scripted setup, provide all arguments upfront:
10xgraph init --yes --name MyWeatherBot --mode full --provider openai --storage postgresPassing --yes or --non-interactive skips all prompts. Any value you omit takes its default (the Quick setup, and for Full the recommended setup). The auth, cache store, rate limit and token revocation flags are only valid with --mode full.
Flags reference
| Flag | Short | Values | Default | Notes |
|---|---|---|---|---|
--path |
-p |
Directory path | . |
Project root |
--name |
String | Directory name of --path, or MyAgent for . |
Agent name and display label | |
--mode |
quick | full |
Prompted, or quick with --yes / --non-interactive |
Dev (quick) or team/deployment mode. --template quick-start|production is an alias |
|
--provider |
google | openai | anthropic |
Prompted | AI provider for the starter agent | |
--auth |
none | jwt | custom |
jwt |
Requires --mode full |
|
--storage |
memory | sqlite | postgres | postgres-memory |
memory |
Requires --mode full. Picks the checkpointer (and the store for postgres-memory) |
|
--cache-store |
memory | redis |
Follows --storage: memory for memory and sqlite, redis for postgres and postgres-memory. redis when --worker is set |
Requires --mode full. memory with a worker is refused |
|
--rate-limit / --no-rate-limit |
Flag | On | Adds or leaves out cache_store.rate_limit |
|
--token-revocation / --no-token-revocation |
Flag | On with auth | Adds or leaves out cache_store.token_revocation. Ignored with --auth none |
|
--websocket / --no-websocket |
Flag | Off | Writes websocket.enabled |
|
--force |
-f |
Flag | Off | Overwrite existing files (careful: replaces graph code) |
--dry-run |
Flag | Off | Print files that would be created; do not write anything | |
--yes |
-y |
Flag | Off | Accept the recommended defaults and do not prompt |
--non-interactive |
Flag | Off | Never prompt; invalid values fail instead of being asked for |
Example with --dry-run:
10xgraph init --name MyBot --mode full --dry-runThis lists files that would be created without touching your filesystem.
What init generates
Quick setup
Minimal setup for rapid prototyping:
10xgraph.json
.env.example
requirements.txt
graph/
__init__.py
agent.py- 10xgraph.json: Server config with just the agent path and env file.
- graph/agent.py: A starter ReAct agent built with
ReactAgent, with a sample weather tool and anappvariable for the server. - .env.example: API key placeholders. Copy to
.env, fill in your credentials. - requirements.txt:
10xgraph[<provider extra>]and10xgraph-api, the packages the agent needs.10xgraph buildinstalls from it, and add extras such asjwthere when you turn a feature on.
Run with:
pip install -r requirements.txt
cp .env.example .env
# Add your provider API key to .env
10xgraph devFull setup
Complete project structure with auth, a cache store, tests, and evaluations:
.pre-commit-config.yaml
.env.example
.python-version
10xgraph.json
pyproject.toml
graph/
__init__.py
agent.py
state.py
tools/
__init__.py
weather_tool.py (example tool)
validators/
__init__.py
lifecyle.py
manager.py
validators.py
auth/ # only if --auth custom
__init__.py
agent_auth.py
worker/ # only if --worker is not none
__init__.py
tasks.py
tests/ # unless tests are turned off
__init__.py
conftest.py
test_graph_nodes.py
test_catalog_tools.py
test_agent_eval.py
evals/ # unless evals are turned off
__init__.py
weather_agents_eval.py
user_simulator_eval.pyWhy each part matters:
- pyproject.toml: Declares your project as a package. Enables
pip install -e .(editable), integratesruff/mypy/pytestconfig, and ensures repeatable environments. - graph/state.py: Custom state schema (inherits from
AgentState). Extend it as your agent’s state grows. - graph/tools/: Custom agent tools as decorated functions.
- graph/validators/: Lifecycle validators (before invoke, after step, on error) and validation manager.
- auth/agent_auth.py: Custom authentication logic (only scaffolded when
--auth custom). ImplementBaseAuthsubclass. - worker/tasks.py: Example background tasks. Only scaffolded when a worker is chosen.
- tests/: Unit tests (mock the model, test state transitions, tool logic).
- .env.example: Conditional blocks for JWT and Redis; only kept in
.envif you selected those options. - .pre-commit-config.yaml: Git hooks for
ruff check/format,bandit,mypy.
How 10xgraph.json is generated
Init builds your config from your answers, not a static template. Examples:
Quick (minimal):
{
"agent": "graph.agent:app",
"env": ".env",
"auth": null,
"thread_name_generator": null,
"ag_ui": {"enabled": false},
"websocket": {"enabled": false}
}Full (the default for --mode full, which means --storage memory, so the cache store is memory; --storage postgres, --storage postgres-memory or --worker write redis):
{
"agent": "graph.agent:app",
"env": ".env",
"auth": {"method": "jwt"},
"thread_name_generator": "first_message",
"ag_ui": {"enabled": false, "allow_client_tools": false},
"websocket": {"enabled": false},
"remote_tools": [],
"injectq": "graph.agent:container",
"id_generator": "uuid",
"cache_store": {
"type": "memory",
"rate_limit": {
"enabled": true,
"requests": 100,
"window": 60,
"by": "user",
"trusted_proxy_headers": false,
"fail_open": false,
"exclude_paths": ["/ping", "/docs", "/redocs", "/openapi.json"]
},
"token_revocation": true
},
"audit": {"enabled": true, "sinks": ["log"], "include_reads": true},
"test": {"path": "tests", "coverage": true, "coverage_threshold": 70},
"evaluation": {
"directory": "evals",
"output_dir": "eval_reports",
"threshold": 0.75,
"parallel": false,
"max_concurrency": 4,
"timestamp_files": true
}
}With "type": "redis" the cache store has no url, so Redis comes from the REDIS_URL environment variable. A worker block is added when you choose a background worker, and "store": "graph.agent:store" when you choose Postgres memory storage. The test and evaluation blocks are left out when tests or evals are turned off.
Full with --auth none: the same file with "auth": null and no token revocation. Rate limiting is then counted by ip.
Thread names. Full writes "thread_name_generator": "first_message". Quick leaves it null, which means none: threads are saved without a name. The other choices are random, or a module:attr path to your own ThreadNameGenerator subclass. See Generate readable thread names.
For full details on every config key, see /docs/server/configure. To see what each key does when it is absent, see What is on by default.
Overwrite and force flags
To regenerate a project’s files:
10xgraph init --forceThis re-runs init in your current directory and overwrites all template files (graph code, tests, validators, auth stub) and 10xgraph.json. Use with care. Without --force, init stops with a “File already exists” error at the first file that is already there.
To preview without writing:
10xgraph init --name MyBot --mode full --dry-runLists files that would be created and exits without modifying the filesystem.
Interactive vs. non-interactive prompts
Interactive (default)
10xgraph initAsks three questions:
- Agent name? (default:
MyAgent) - Quick or Full? (default: Quick)
- AI provider? (Google, OpenAI or Anthropic)
Nothing else is asked. Full writes the recommended config and lists it in the summary. Run 10xgraph config afterwards to change WebSocket, AG-UI, the ID generator, thread naming and every other setting.
Non-interactive with defaults
10xgraph init --yesUses all defaults: agent name inferred from directory, Quick setup, no auth, no cache store.
Non-interactive with explicit arguments
10xgraph init --yes --name WeatherBot --mode full --auth jwt --cache-store memoryDoes not prompt; an invalid value fails with an error.
After init: next steps
1. Set up your environment
cp .env.example .env
# Edit .env and add your provider API key(s)
# If using JWT auth, add JWT_SECRET_KEY (32+ characters) and JWT_ALGORITHM
# If using Redis rate limiting, add REDIS_URL2. Install coding-assistant skills (optional but recommended)
10xgraph skillsInstalls the bundled 10xGraph skills for Codex, Claude Code or GitHub Copilot (pick one with --agent or use --all), so your coding assistant knows the framework.
3. (Full only) Set up Git hooks
pre-commit installLints your code automatically on each commit.
4. Test that the graph loads
python -c "from graph.agent import app; print(app)"If this fails, check that graph/agent.py is syntactically correct and imports are available.
5. Start the server
10xgraph devStarts the API on localhost:8000 and opens the web playground.
Troubleshooting
“ModuleNotFoundError: No module named ‘tenxgraph_api’”
Install the API package:
pip install 10xgraph-api“File already exists” error during init
A file is in the way. Either:
- Move it aside:
mv <filename> <filename>.bak - Pass
--force:10xgraph init --force(overwrites all template files) - Use
--pathto target a different directory:10xgraph init --path ./new-dir
“ModuleNotFoundError: No module named ‘graph’” after init
The graph module didn’t load when the server started. Check:
- Is
graph/agent.pypresent and syntactically valid? - Does
graph/agent.pydefine anappvariable that is a compiledStateGraph? - Are all imports in
graph/agent.pyinstalled? (e.g.,pip install "10xgraph[google-genai]") - Run
python -c "from graph.agent import app; print(app)"to get a detailed error.
“Invalid mode” or “Invalid auth mode”
You passed an unrecognized value to --mode, --auth, or --cache-store. Valid values:
--mode:quick,full(the alias--templatetakesquick-start,production)--auth:none,jwt,custom--cache-store:memory,redis
Auth, cache store, rate-limit and token-revocation flags only work with --mode full.
Agent name contains special characters
Init slugifies your agent name (e.g. My Agent 2024 becomes my-agent-2024). Use alphanumerics, hyphens, and spaces; other characters may be stripped or cause module import errors.
Related pages
/docs/server/configure: Full reference for every 10xgraph.json key and environment variable./docs/server/run-the-server: Starting the API server in development and production./docs/server/auth: Authentication and authorization setup.
Frequently asked questions
- What is the difference between the Quick and Full setups?
- Quick generates a minimal graph with 10xgraph.json and environment template. Full adds tests, evaluations, auth stubs, and a full project structure, and writes the recommended config: JWT auth with owner-only data, a UUID ID generator, and a cache store with rate limiting and token revocation. The cache store is memory with the default memory storage and Redis with Postgres storage or a worker.
- Can I change the setup or auth choice after scaffolding?
- Yes, re-run 10xgraph init with --force to regenerate, or edit 10xgraph.json directly. See server/configure for full config reference.
- When should I choose a memory cache store instead of Redis?
- A memory cache store works for single instances only. Use Redis when running multiple server replicas or containers that need shared counters, locks and token revocation.