f2d

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:

PrioritySourceHow to set
1 (highest)Command-line flag--api-key <key>
2Environment variableexport F2D_API_KEY="<key>"
3Configuration filef2d configure or f2d config set api-key <key>
4 (lowest)Built-in defaultEndpoint 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:

ProtectionDetail
EncryptionAES-256-CBC
Key derivationPBKDF2 with SHA-512, 100,000 iterations
Key materialDerived from machine identity (hostname + username)
File permissionschmod 600 — only the file owner can read/write
Display maskingf2d config list shows only first 4 and last 4 characters
Corruption handlingIf decryption fails, the corrupted file is deleted and you're prompted to reconfigure

~/.f2drc is bound to your machine and user account. If you change machines, run f2d configure again.

Viewing Configuration

f2d config list
Configuration (~/.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

VariableDescriptionExample
F2D_API_KEYAPI keyexport F2D_API_KEY="<your-api-key>"
F2D_ENDPOINTAPI base URLexport 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:

  1. f2d configure — interactive setup (recommended)
  2. export F2D_API_KEY="<your-api-key>" — environment variable
  3. f2d 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

ErrorCauseSolution
Timeout / slow responseFirst request cold startNormal — wait 3-5 seconds, retry
403 Invalid API keyWrong API keyRun f2d configure to reset
429 Rate limit exceededToo many requestsWait and retry after a moment
Network errorConnectivity issueCheck internet connection and endpoint URL

Next Steps

On this page