Configuration
API key management, priority resolution, and configuration file security
API Key Resolution
f2d resolves your API key (and endpoint) using the following priority order. The first match wins:
| Priority | Source | How to set |
|---|---|---|
| 1 (highest) | Command-line flag | --api-key <key> |
| 2 | Environment variable | export F2D_API_KEY="<key>" |
| 3 | Configuration file | f2d configure or f2d config set api-key <key> |
| 4 (lowest) | Built-in default | Endpoint only (no default API key) |
The same priority applies to the endpoint, using --endpoint, F2D_ENDPOINT, or the config file respectively. The default endpoint is built-in, so you typically only need to configure your API key.
Examples
# Method 1: Configuration file (recommended — set once, use forever)
f2d configure
f2d search "Python developer"
# Method 2: Environment variable (useful for CI/scripts)
export F2D_API_KEY="<your-api-key>"
f2d search "Python developer"
# Method 3: Command-line flag (one-off override)
f2d search "Python developer" --api-key <your-api-key>Configuration File
f2d stores configuration in ~/.f2drc. This file is created by f2d configure or f2d config set.
Security
Your API key is stored encrypted, not in plain text:
| Protection | Detail |
|---|---|
| Encryption | AES-256-CBC |
| Key derivation | PBKDF2 with SHA-512, 100,000 iterations |
| Key material | Derived from machine identity (hostname + username) |
| File permissions | chmod 600 — only the file owner can read/write |
| Display masking | f2d config list shows only first 4 and last 4 characters |
| Corruption handling | If decryption fails, the corrupted file is deleted and you're prompted to reconfigure |
~/.f2drcis bound to your machine and user account. If you change machines, runf2d configureagain.
Viewing Configuration
f2d config listConfiguration (~/.f2drc):
api-key: cfc6****f582
endpoint: https://...Updating Configuration
# Interactive (recommended)
f2d configure
# Direct update
f2d config set api-key <your-new-api-key>Environment Variables
| Variable | Description | Example |
|---|---|---|
F2D_API_KEY | API key | export F2D_API_KEY="<your-api-key>" |
F2D_ENDPOINT | API base URL | export F2D_ENDPOINT="<your-endpoint-url>" |
Environment variables override the config file but are overridden by command-line flags.
FAQ
"API key not found" — how do I fix this?
f2d couldn't find an API key from any source. Fix it with one of:
f2d configure— interactive setup (recommended)export F2D_API_KEY="<your-api-key>"— environment variablef2d search "query" --api-key <your-api-key>— inline flag
"Endpoint not found" — what should I do?
The default endpoint is built-in, so this is rare. If you see this error, set the endpoint explicitly:
f2d config set endpoint <your-endpoint-url>Where is the config file stored?
~/.f2drc in your home directory. The file is encrypted — do not edit it manually.
Can I use f2d in CI/CD pipelines?
Yes. Set F2D_API_KEY as a secret environment variable in your CI system. No config file needed.
Request times out or returns an error
| Error | Cause | Solution |
|---|---|---|
| Timeout / slow response | First request cold start | Normal — wait 3-5 seconds, retry |
403 Invalid API key | Wrong API key | Run f2d configure to reset |
429 Rate limit exceeded | Too many requests | Wait and retry after a moment |
| Network error | Connectivity issue | Check internet connection and endpoint URL |
Next Steps
- CLI Commands — full command reference
- REST API Quick Start — alternative HTTP-based access