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

# Generate a client SDK

> Generate a typed Python or TypeScript client from ZeroDrift's public OpenAPI spec

ZeroDrift publishes the public API as an OpenAPI 3.0 document. You generate a typed client from that file; ZeroDrift does not ship a first-party SDK package.

The spec lives at:

```text theme={null}
https://docs.zerodrift.com/openapi.json
```

See [OpenAPI specification](/api-reference/openapi) for the operations it covers. Authenticate every call with the `x-api-key` header. Base URL is `https://api.zerodrift.ai`.

## Generate with an assistant

Download the spec, attach `openapi.json` to your coding assistant, and ask it to write a typed client. Name the API groups you need so the generated file covers them.

<Frame caption="Attach openapi.json and ask an assistant to generate a typed TypeScript client.">
  <video controls className="w-full rounded-xl" src="https://mintcdn.com/zerodrift/DrMiNhqXX6QHXds_/images/generate-sdk-howto.mp4?fit=max&auto=format&n=DrMiNhqXX6QHXds_&q=85&s=e36b95ceb8afa25b23dc9314cf5212f4" data-path="images/generate-sdk-howto.mp4">
    Your browser does not support the video tag.
  </video>
</Frame>

Example prompt:

```text theme={null}
Write a typed TypeScript client for this API — cover enforce, policy, activity, and rule packs.
```

Use `https://docs.zerodrift.com/openapi.json` as the source, not a path on `api.zerodrift.ai`. After generation, confirm the client sends `x-api-key` and calls `https://api.zerodrift.ai`.

## TypeScript with openapi-typescript

[`openapi-typescript`](https://github.com/openapi-ts/openapi-typescript) turns the spec into TypeScript types. It does not emit an HTTP client; you call `fetch` (or your own wrapper) and type the requests with the generated `paths` interface.

```bash theme={null}
npx --yes openapi-typescript https://docs.zerodrift.com/openapi.json -o zerodrift.ts
```

That command writes `zerodrift.ts` with `paths` and `components`. Use it like this:

```ts theme={null}
import type { paths } from "./zerodrift";

const BASE_URL = "https://api.zerodrift.ai";

type ValidateBody =
  paths["/api/v3/content/validate"]["post"]["requestBody"]["content"]["application/json"];

type ValidateResponse =
  paths["/api/v3/content/validate"]["post"]["responses"]["200"]["content"]["application/json"]
  | paths["/api/v3/content/validate"]["post"]["responses"]["202"]["content"]["application/json"];

export async function validateContent(
  apiKey: string,
  body: ValidateBody
): Promise<ValidateResponse> {
  const response = await fetch(`${BASE_URL}/api/v3/content/validate`, {
    method: "POST",
    headers: {
      "x-api-key": apiKey,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(body),
  });

  if (!response.ok) {
    throw new Error(`ZeroDrift API error ${response.status}: ${await response.text()}`);
  }

  return response.json() as Promise<ValidateResponse>;
}

const result = await validateContent("YOUR_API_KEY", {
  content: "Our fund guarantees 20% returns with zero risk!",
  document_category: "scenario_retail_investor_letter",
  mode: "sync",
  model_engine: "anchor_3_0",
});
```

Regenerate `zerodrift.ts` when you pick up a new spec.

## Python with OpenAPI Generator

[OpenAPI Generator](https://openapi-generator.tech/) emits a full Python client. It needs Java, or Docker.

```bash theme={null}
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
  -i https://docs.zerodrift.com/openapi.json \
  -g python \
  -o /local/zerodrift-python \
  --additional-properties=packageName=zerodrift
```

Follow the generated README. Set the API key on the `ApiKeyHeader` scheme (the `x-api-key` header) and use host `https://api.zerodrift.ai`.

If you do not want Java or Docker, [`openapi-python-client`](https://github.com/openapi-generators/openapi-python-client) generates a typed httpx client from the same URL:

```bash theme={null}
pip install openapi-python-client
openapi-python-client generate --url https://docs.zerodrift.com/openapi.json
```

That writes a package named from the spec title (`zero_drift_enforcement_api_client`). Pass the API key as a header. Do not use the default `Authorization: Bearer` client unless you override the header name.

```python theme={null}
from zero_drift_enforcement_api_client import Client
from zero_drift_enforcement_api_client.api.validate import validate_content
from zero_drift_enforcement_api_client.models import (
    ItemValidateV3Email,
    ItemValidateV3EmailMode,
    ItemValidateV3EmailModelEngine,
)

client = Client(
    base_url="https://api.zerodrift.ai",
    headers={"x-api-key": "YOUR_API_KEY"},
)

result = validate_content.sync(
    client=client,
    body=ItemValidateV3Email(
        content="Our fund guarantees 20% returns with zero risk!",
        document_category="scenario_retail_investor_letter",
        mode=ItemValidateV3EmailMode.SYNC,
        model_engine=ItemValidateV3EmailModelEngine.ANCHOR_3_0,
    ),
)
```

Install the generated package into your environment (for example `pip install ./zero-drift-public-api-client`) before you import it.

## Other languages

The same spec URL works with any OpenAPI 3.0 generator (`-g typescript-fetch`, Go, and so on). After codegen, check three things:

1. Requests go to `https://api.zerodrift.ai`
2. The API key is sent as `x-api-key`, not `Authorization`
3. You regenerate the client when the spec changes

<Note>
  ZeroDrift does not publish `pip install zerodrift` or `npm i @zerodrift/sdk`. Keep the generated client in your repo or private registry.
</Note>

API reference pages also show basic request examples. Use the language selector in the upper right for **cURL**, **Python**, **JavaScript**, **PHP**, **Go**, **Java**, or **Ruby**.
