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

# Integrations

> OpenAI, Anthropic, Google GenAI, LangChain, and Google ADK

The Flint AI TypeScript SDK supports the same integrations as the Python SDK. Standard LLM clients use `wrap()`, while Google ADK uses a dedicated plugin.

| Integration                                                         | Method                |
| ------------------------------------------------------------------- | --------------------- |
| OpenAI                                                              | `wrap()`              |
| Anthropic                                                           | `wrap()`              |
| Google GenAI                                                        | `wrap()`              |
| LangChain (`ChatOpenAI`, `ChatAnthropic`, `ChatGoogleGenerativeAI`) | `wrap()`              |
| Google ADK                                                          | `ADKGuardrailsPlugin` |

## OpenAI

Wrap an `OpenAI` client to route completions through the guardrails proxy.

```typescript theme={null}
import OpenAI from "openai";
import { wrap } from "@sandboxaq/flintai-sdk-ts";

const client = new OpenAI({ apiKey: "your-openai-api-key" });
wrap(client, {
  gatewayUrl: "https://app.flintai.dev",
  apiKey: "your-flintai-api-key",
});

const response = await client.chat.completions.create({
  model: "gpt-4",
  messages: [{ role: "user", content: "Hello" }],
});
```

After wrapping, use the client exactly as before — the SDK redirects traffic transparently.

## Anthropic

Wrap an `Anthropic` client the same way.

```typescript theme={null}
import Anthropic from "@anthropic-ai/sdk";
import { wrap } from "@sandboxaq/flintai-sdk-ts";

const client = new Anthropic({ apiKey: "your-anthropic-api-key" });
wrap(client, {
  gatewayUrl: "https://app.flintai.dev",
  apiKey: "your-flintai-api-key",
});

const message = await client.messages.create({
  model: "claude-sonnet-4-20250514",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello" }],
});
```

## Google GenAI

Wrap a `GoogleGenAI` client. Set your Gemini key the way you normally would (shown here on the client). The SDK does not require any additional LLM provider key of its own.

```typescript theme={null}
import { GoogleGenAI } from "@google/genai";
import { wrap } from "@sandboxaq/flintai-sdk-ts";

const client = new GoogleGenAI({ apiKey: "your-gemini-api-key" });
wrap(client, {
  gatewayUrl: "https://app.flintai.dev",
  apiKey: "your-flintai-api-key",
});

const response = await client.models.generateContent({
  model: "gemini-2.5-flash",
  contents: "Hello",
});
```

<Note>
  The SDK normalizes the gateway URL with a trailing slash for Google GenAI — do not add one yourself.
</Note>

## LangChain

`wrap()` auto-detects LangChain chat models, extracts the underlying SDK client, and applies guardrails routing. Supported models:

* `ChatOpenAI` (from `@langchain/openai`)
* `ChatAnthropic` (from `@langchain/anthropic`)
* `ChatGoogleGenerativeAI` (from `@langchain/google-genai`)

```typescript theme={null}
import { ChatOpenAI } from "@langchain/openai";
import { wrap } from "@sandboxaq/flintai-sdk-ts";

const llm = new ChatOpenAI({ model: "gpt-4" });
wrap(llm, {
  gatewayUrl: "https://app.flintai.dev",
  apiKey: "your-flintai-api-key",
});

const response = await llm.invoke("Hello");
```

<Tabs>
  <Tab title="ChatAnthropic">
    ```typescript theme={null}
    import { ChatAnthropic } from "@langchain/anthropic";
    import { wrap } from "@sandboxaq/flintai-sdk-ts";

    const llm = new ChatAnthropic({ model: "claude-sonnet-4-20250514" });
    wrap(llm, {
      gatewayUrl: "https://app.flintai.dev",
      apiKey: "your-flintai-api-key",
    });

    const response = await llm.invoke("Hello");
    ```
  </Tab>

  <Tab title="ChatGoogleGenerativeAI">
    ```typescript theme={null}
    import { ChatGoogleGenerativeAI } from "@langchain/google-genai";
    import { wrap } from "@sandboxaq/flintai-sdk-ts";

    const llm = new ChatGoogleGenerativeAI({ model: "gemini-2.5-flash" });
    wrap(llm, {
      gatewayUrl: "https://app.flintai.dev",
      apiKey: "your-flintai-api-key",
    });

    const response = await llm.invoke("Hello");
    ```
  </Tab>
</Tabs>

## Google ADK

ADK agents lazily create their GenAI client at runtime, so `wrap()` cannot be used. Use `ADKGuardrailsPlugin` to configure guardrails routing at the agent level:

```typescript theme={null}
import { ADKGuardrailsPlugin } from "@sandboxaq/flintai-sdk-ts/plugins/adk";
import { Agent } from "@google/adk";

const plugin = new ADKGuardrailsPlugin({
  gatewayUrl: "https://app.flintai.dev",
  apiKey: "your-flintai-api-key",
});

const agent = new Agent({
  model: "gemini-2.5-flash",
  generateContentConfig: plugin.contentConfig,
  beforeModelCallback: plugin.beforeModelCallback,
  onModelErrorCallback: ADKGuardrailsPlugin.onModelError,
});
```

The plugin handles three concerns:

* **Routing** — `contentConfig` directs LLM traffic through the guardrails proxy.
* **Identity** — `beforeModelCallback` attaches the ADK session ID as an `X-Agent-Session-Id` header on each call.
* **Error handling** — the static `ADKGuardrailsPlugin.onModelError` converts guardrails blocks into an `LlmResponse` the agent can handle gracefully.

See [Usage](/flintai/platform/sdk/typescript/usage#google-adk) for the `contentConfig` cloning caveat.

## Version compatibility

Pin your provider SDK to the tested ranges to avoid breakage from private API changes:

| Provider package          | Supported range |
| ------------------------- | --------------- |
| `openai`                  | `^6.41.0`       |
| `@anthropic-ai/sdk`       | `^0.100.1`      |
| `@google/genai`           | `^2.8.0`        |
| `@google/adk`             | `^1.2.0`        |
| `@langchain/openai`       | `^1.4.7`        |
| `@langchain/anthropic`    | `^1.4.0`        |
| `@langchain/google-genai` | `^2.1.31`       |

For the three LLM SDKs, `wrap()` resolves the installed version and throws if it falls outside the supported range.

## Known limitations

* **Private attribute mutation** — `wrap()` redirects traffic by rewriting each client's base URL and injecting the guardrails headers (`X-FlintAI-API-Key`, `X-Guardrails-Policy-Id`). For OpenAI and Anthropic this uses the internal `_options.defaultHeaders`, and for Google the internal `apiClient.clientOptions.httpOptions`. These internal attributes are not part of the providers' public APIs and may change without notice, so pin your provider SDK versions to the tested ranges.
* **Google GenAI URL normalization** — the Google GenAI SDK requires a trailing slash on the base URL. The SDK adds it automatically — do not add one to `gatewayUrl`.
* **Multiple provider keys in environment** — if several provider API keys are set (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GOOGLE_API_KEY`), auto-detection fails. Pass `provider` explicitly to `init()`.

## Next steps

<CardGroup cols={2}>
  <Card title="Usage" icon="code" href="/flintai/platform/sdk/typescript/usage">
    Advanced patterns, error handling, and best practices
  </Card>

  <Card title="Configuration" icon="sliders" href="/flintai/platform/sdk/typescript/configuration">
    Environment variables, credentials, and gateway setup
  </Card>
</CardGroup>
