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

# Generate clients

> Generate typed clients from the Vantr OpenAPI spec.

# Generate clients

The committed OpenAPI spec is served from this docs site at `/openapi/v2.json`. Use it to generate clients for your integration stack.

<Check>
  The spec is generated from the API source before it is pushed, then Mintlify builds the API reference from that same file.
</Check>

## Generate from the docs spec

<CodeGroup>
  ```bash TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  npx @openapitools/openapi-generator-cli generate \
    -i "$DOCS_URL/openapi/v2.json" \
    -g typescript-fetch \
    -o vantr-client
  ```

  ```bash Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  npx @openapitools/openapi-generator-cli generate \
    -i "$DOCS_URL/openapi/v2.json" \
    -g python \
    -o vantr_client
  ```

  ```bash Go theme={"theme":{"light":"github-light","dark":"github-dark"}}
  npx @openapitools/openapi-generator-cli generate \
    -i "$DOCS_URL/openapi/v2.json" \
    -g go \
    -o vantr-go
  ```
</CodeGroup>

## Wrap generated clients

Generated code is easier to use when auth, base URL, and non-2xx handling live in one wrapper.

<CodeGroup>
  ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const baseUrl = process.env.VANTR_BASE_URL ?? 'https://api.vantr.ai';
  const credentials = Buffer
    .from(`${process.env.VANTR_CLIENT_ID}:${process.env.VANTR_CLIENT_SECRET}`)
    .toString('base64');

  export async function invoiceEdgeFetch(path: string, init: RequestInit = {}) {
    const response = await fetch(`${baseUrl}${path}`, {
      ...init,
      headers: {
        Authorization: `Basic ${credentials}`,
        'Content-Type': 'application/json',
        ...init.headers,
      },
    });

    if (!response.ok) {
      const body = await response.text();
      throw new Error(`Vantr ${response.status}: ${body}`);
    }

    return response.json();
  }
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import os
  import requests

  class VantrClient:
      def __init__(self):
          self.base_url = os.getenv("VANTR_BASE_URL", "https://api.vantr.ai")
          self.auth = (
              os.environ["VANTR_CLIENT_ID"],
              os.environ["VANTR_CLIENT_SECRET"],
          )

      def request(self, method, path, **kwargs):
          response = requests.request(
              method,
              f"{self.base_url}{path}",
              auth=self.auth,
              timeout=20,
              **kwargs,
          )
          response.raise_for_status()
          return response.json()
  ```
</CodeGroup>

## Recommended client shape

<Columns cols={2}>
  <Card title="Centralize auth" icon="key-round" horizontal>
    Put client credential handling in one HTTP client wrapper.
  </Card>

  <Card title="Handle non-2xx responses" icon="triangle-alert" horizontal>
    Treat OAuth errors and v2 error bodies as structured responses.
  </Card>

  <Card title="Regenerate deliberately" icon="refresh-cw" horizontal>
    Commit generated clients with the spec version that produced them.
  </Card>

  <Card title="Pin your generator" icon="pin" horizontal>
    Use a fixed OpenAPI generator version in CI for repeatable output.
  </Card>
</Columns>

## Pre-push check

Run the developer docs check before pushing documentation or API reference changes.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
npm run docs:developer:check
```

This verifies that the generated spec is current, Mintlify can read every referenced page, and the OpenAPI document uses only internal `$ref` values.
