nika agent
The agent command is the unified AI interface for Nika CLI. It reads the
provider and model from .nika.toml, sends normal prompts to that provider,
and detects prompts that request module or route changes.
Configure a provider
The command creates or updates the [agent] section in .nika.toml while
preserving the build configuration.
Providers
| Provider | Default model | Default endpoint | API key |
|---|---|---|---|
ollama |
gemma3:4b |
http://localhost:11434 |
Not required |
9router |
openai/gpt-4o-mini |
OpenRouter OpenAI-compatible API | OPENROUTER_API_KEY |
chatgpt |
gpt-4o-mini |
OpenAI API | OPENAI_API_KEY |
API keys are never written to .nika.toml; only the environment variable name
is stored. Set the variable before running the command for cloud providers.
Run a prompt
The command requires an initialized .nika.toml. A normal prompt is sent to
the configured provider and the response is printed.
Generate a module
Prompts containing module creation intent are converted into a structured
resource definition and passed to the same generator used by nika generate res:
The generated module includes schema, DTO, service, controller, response, and module files. The model name and field types are validated before files are written.
Add a route
Prompts that mention a route, endpoint, mock, or mock data use the route workflow:
The workflow:
- Identifies the requested module and verifies
src/<module>exists. - Checks the module model and currently supports MongoDB models.
- Finds controller structs under
src/<module>/controllers. - Asks which controller to use when more than one controller exists.
- Uses the model definition and AI plan to create
controllers/mock.go. - Registers the route on the selected controller.
The generated handler uses the controller field and handler method separately:
CreateMock func(*gin.Context) `route:"POST:/newss/mock"`
// in the constructor
c.CreateMock = c.CreateMockHandler
The generated CreateMockHandler includes Swagger annotations and calls the
module's existing Create service method.
Install project AI files
Running the command without a prompt installs Nika-specific agent files under
.github:
This is separate from provider initialization. Use nika agent init <provider>
to configure .nika.toml, and nika agent without arguments to install project
instructions, prompts, and skills.