> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runflow.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration File

> Configure Runflow SDK with .runflow/rf.json

## Configuration File

Create a `.runflow/rf.json` file:

```json theme={null}
{
  "agentId": "your_agent_id",
  "tenantId": "your_tenant_id",
  "apiKey": "your_api_key",
  "apiUrl": "http://localhost:3001"
}
```

The SDK automatically searches for `.runflow/rf.json` in the current directory and parent directories.

<Tip>
  When you run `rf create` or `rf agents clone`, the `.runflow/rf.json` file is created automatically with the correct values.
</Tip>

## Using config outside the SDK

By default, the SDK reads `rf.json` internally when creating agents and API clients. But if you need the config available to **external tools** (Promptfoo, custom test scripts, CI pipelines, or any Node.js process), add a single import:

```typescript theme={null}
import '@runflow-ai/sdk/init';
```

This reads `.runflow/rf.json` and sets the following environment variables in `process.env`:

| rf.json field | Environment variable |
| ------------- | -------------------- |
| `apiUrl`      | `RUNFLOW_API_URL`    |
| `apiKey`      | `RUNFLOW_API_KEY`    |
| `tenantId`    | `RUNFLOW_TENANT_ID`  |
| `agentId`     | `RUNFLOW_AGENT_ID`   |

Existing environment variables are **never overwritten** — explicit env vars always take priority over rf.json values.

### Examples

**Promptfoo config:**

```typescript promptfooconfig.ts theme={null}
import '@runflow-ai/sdk/init';

// process.env.RUNFLOW_API_URL is now available
export default {
  providers: [{
    id: 'runflow',
    config: { apiUrl: process.env.RUNFLOW_API_URL },
  }],
};
```

**Custom test script:**

```typescript test.ts theme={null}
import '@runflow-ai/sdk/init';
import { main } from './main';

// Your agent can resolve its config automatically
const result = await main({ message: 'Hello' });
console.log(result);
```

**Any standalone script:**

```typescript scripts/check-agent.ts theme={null}
import '@runflow-ai/sdk/init';

console.log('Agent ID:', process.env.RUNFLOW_AGENT_ID);
console.log('API URL:', process.env.RUNFLOW_API_URL);
```

<Info>
  `init` is idempotent — safe to import multiple times from different files. It reads `rf.json` once and skips subsequent calls.
</Info>

## Configuration Priority

1. Explicit config in code
2. `.runflow/rf.json`
3. Environment variables
4. Defaults

## Next Steps

<CardGroup cols={2}>
  <Card title="CLI Login" icon="key" href="/cli/login">
    Authenticate and manage profiles
  </Card>

  <Card title="Troubleshooting" icon="wrench" href="/troubleshooting/common-issues">
    Resolve common issues
  </Card>
</CardGroup>
