apicentric.json file is the main configuration file for Apicentric. It defines global settings for AI code generation and the API simulator.
Location
By default, Apicentric looks forapicentric.json in your project root directory.
Creating a configuration file
You can generate a default configuration file using the CLI:apicentric.json file with sensible defaults that you can customize for your project.
Configuration structure
The configuration file uses JSON format with two main sections:ai and simulator.
Example configuration
AI configuration
Configure AI-assisted code generation features.AI generation configuration
The AI provider to use for text generation.Options:
openai- Use OpenAI APIgemini- Use Google Gemini APIlocal- Use a local language model
API key for the selected provider. Required for
openai and gemini providers.For Gemini, you can also set the GEMINI_API_KEY environment variable instead of storing the key in the config file.For security, consider using environment variables instead of storing API keys directly in configuration files.
Model identifier for the AI provider.Examples:
- OpenAI:
gpt-4,gpt-3.5-turbo - Gemini:
gemini-2.5-flash,gemini-pro
Path to the local model when using the
local provider. Required only for local models.Simulator configuration
Configure the API simulator that runs your service definitions.API simulator configuration
Whether the simulator is enabled. Set to
true to activate the simulator.Default: falseDirectory containing service definition YAML files. The simulator watches this directory for changes.Default:
servicesPath to SQLite database file for persistent storage of service state.Default:
apicentric.dbPort for the admin API server. If not specified, the admin API is disabled.Default:
null (disabled)Global behavior settings that apply to all services unless overridden.
Simulate random errors for testing error handling.
Enable error simulation.
Error rate between 0.0 and 1.0 (e.g., 0.1 = 10% error rate).
Array of HTTP status codes to return when simulating errors.Example:
[500, 502, 503]Validation
Apicentric validates your configuration file when loading it. Common validation errors include:- Missing required API keys for the selected AI provider
- Invalid port numbers (must be >= 1024)
- Invalid JSON syntax
- Missing required fields
Best practices
- Use environment variables for secrets - Store API keys in environment variables instead of committing them to version control
- Keep port ranges reasonable - Use port ranges that don’t conflict with other services on your system
- Enable global behaviors for testing - Use latency and error simulation to test your application’s resilience
- Use descriptive service directories - Organize your service definitions in a clear directory structure
Related pages
- service.yaml - Service definition file format
- Environment Variables - Environment variable reference