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

# Configuration

## ClientConfig

```typescript theme={null}
interface ClientConfig {
  apiKey: string;
  baseUrl: string;
  timeout?: number;
  retryConfig?: RetryConfig;
  logger?: Logger;
}
```

## Options

### apiKey

**Type:** `string` (required)

Your Graphy API key (starts with `graphy_`). [Create one in the console](/agents/api-keys).

```typescript theme={null}
const ai = new GraphyAiSdk({
  apiKey: 'graphy_...',
  baseUrl: 'https://agents.graphy.dev',
});
```

### baseUrl

**Type:** `string` (required)

The API base URL. Use `https://agents.graphy.dev` for production.

### timeout

**Type:** `number` (optional)
**Default:** `60000` (60 seconds)

Request timeout in milliseconds. The timeout applies to the initial connection. Once streaming begins, the timeout resets for each chunk.

```typescript theme={null}
const ai = new GraphyAiSdk({
  apiKey: process.env.GRAPHY_API_KEY,
  baseUrl: 'https://agents.graphy.dev',
  timeout: 30000, // 30 seconds
});
```

### retryConfig

**Type:** `RetryConfig` (optional)

```typescript theme={null}
interface RetryConfig {
  attempts: number; // Max retry attempts (default: 3)
  delay: number; // Initial delay in ms (default: 1000)
  backoff: number; // Backoff multiplier (default: 2)
}
```

**Defaults:**

* `attempts`: 3
* `delay`: 1000ms
* `backoff`: 2

Retry delay formula: `delay * (backoff ^ (attempt - 1))`

With defaults:

* Attempt 1: immediate
* Attempt 2: 1000ms delay
* Attempt 3: 2000ms delay

**Retryable conditions:**

* HTTP 5xx errors
* HTTP 429 (rate limit)
* Network failures

**Non-retryable conditions:**

* HTTP 4xx errors (except 429)
* User abort signals

```typescript theme={null}
const ai = new GraphyAiSdk({
  apiKey: process.env.GRAPHY_API_KEY,
  baseUrl: 'https://agents.graphy.dev',
  retryConfig: {
    attempts: 5,
    delay: 500,
    backoff: 1.5,
  },
});
```

### logger

**Type:** `Logger` (optional)

```typescript theme={null}
interface Logger {
  log: (...args: unknown[]) => void;
  warn: (...args: unknown[]) => void;
  error: (...args: unknown[]) => void;
  debug: (...args: unknown[]) => void;
}
```

**Default:** Uses `console.log`, `console.warn`, `console.error`, `console.debug`

Provide a custom logger to integrate with your logging infrastructure (e.g., pino, winston).

## Full Example

```typescript theme={null}
import { GraphyAiSdk } from '@graphysdk/agents-sdk';

const ai = new GraphyAiSdk({
  apiKey: process.env.GRAPHY_API_KEY,
  baseUrl: 'https://agents.graphy.dev',
  timeout: 45000,
  retryConfig: {
    attempts: 3,
    delay: 1000,
    backoff: 2,
  },
  logger: console,
});
```

## Health Check

Use `ping()` to verify connectivity and measure latency:

```typescript theme={null}
const health = await ai.ping();

if (health.ok) {
  console.log(`Connected. Latency: ${health.latency}ms`);
} else {
  console.error('Connection failed');
}
```

**Response:**

```typescript theme={null}
interface PingResponse {
  ok: boolean;
  latency: number; // milliseconds
}
```
