Skip to main content
If you have an API with an OpenAPI (Swagger) specification, the AI can generate a fully typed TypeScript client for it. This gives your Vybe app type-safe access to every endpoint in the API, with auto-complete and compile-time validation.

When to use this

Use OpenAPI client generation when:
  • Your API has an OpenAPI 2.0 (Swagger) or OpenAPI 3.x specification
  • The API has many endpoints and you want type-safe access to all of them
  • You want the AI to understand the full API surface so it can generate accurate code
  • You have an internal service with a published spec
For simpler APIs with just a few endpoints, a Custom API with environment variable injection may be enough.
ApproachBest for
OpenAPI clientComplex APIs with many endpoints, typed requests/responses, internal services with specs
Custom APISimple key-based access, APIs with a few endpoints, services without an OpenAPI spec

How it works

1

Provide the OpenAPI spec

Tell the AI where to find your API’s OpenAPI specification. You can either:
  • Share a URL: Give the AI the URL to your spec (e.g., https://api.example.com/openapi.json)
  • Paste the spec: Copy and paste the YAML or JSON spec directly into the chat
Generate a typed API client from this OpenAPI spec: https://api.example.com/openapi.json
2

AI generates the client

The AI reads the specification and generates a TypeScript client that includes:
  • Type definitions for all request and response schemas
  • Client functions for every endpoint in the spec
  • Authentication handling using your configured credentials
  • Error types for documented error responses
3

Use the client in your app

The generated client is added to your app’s codebase. The AI uses it when building features that call the API, giving you full type safety.

What gets generated

The AI generates a client tailored to your API’s specification. A typical generated client includes:

Type-safe request and response types

Every endpoint’s request body, query parameters, path parameters, and response type are defined as TypeScript interfaces. This means your editor provides auto-complete and the compiler catches type mismatches.

Endpoint functions

Each API endpoint becomes a typed function. For example, an API with a GET /users/{id} endpoint would get a function like:
// The AI generates typed functions for each endpoint
const user = await apiClient.getUser({ id: 'user-123' });
// user is fully typed with all fields from the API response

Authentication handling

The client includes authentication based on the spec’s security definitions. If your API uses Bearer tokens, API keys, or OAuth, the generated client handles the headers automatically using your configured credentials.

Example workflow

Here is a typical workflow for using OpenAPI client generation:
  1. You: “I have an internal inventory API at https://inventory.internal.io. Here is the OpenAPI spec: [paste or URL]”
  2. AI: Reads the spec, identifies the endpoints, and generates a typed client.
  3. You: “Build a page that shows all products with low stock and lets me reorder them.”
  4. AI: Uses the generated client to call the GET /products?stock_level=low endpoint and the POST /orders endpoint, with full type safety.
Because the AI has the complete API specification, it knows exactly which endpoints are available, what parameters they accept, and what the responses look like. This means fewer errors and more accurate code generation.

Updating the client

If your API spec changes — new endpoints, updated schemas, or modified parameters — you can ask the AI to regenerate the client:
The inventory API spec has been updated. Regenerate the TypeScript client from https://inventory.internal.io/openapi.json
The AI will update the generated types and functions to match the new spec. Any app code that uses removed or changed endpoints will surface as TypeScript errors, making it easy to identify what needs to be updated.

Combining with Custom APIs

You can use OpenAPI client generation together with Custom APIs. A common pattern is:
  1. Create a Custom API to securely store your API credentials (API key, Bearer token, etc.)
  2. Generate an OpenAPI client for type-safe endpoint access
  3. The generated client uses the Custom API’s environment variable for authentication
This gives you both secure credential management and typed API access.
If your API requires authentication, set up a Custom API for the credentials before generating the OpenAPI client. The AI will wire them together automatically.

Supported specifications

The AI can generate clients from:
FormatVersions
OpenAPI3.0.x, 3.1.x
Swagger2.0
Both JSON and YAML formats are supported. The spec can be provided as a URL or pasted directly into the chat.

Limitations

  • Server-side only — Generated clients are used in API routes and server components. They cannot be called from client-side code.
  • REST APIs — OpenAPI client generation works with REST APIs. For GraphQL APIs, the AI can generate queries directly without a client generator.
  • Spec quality matters — The accuracy of the generated client depends on the quality of the OpenAPI spec. Specs with incomplete type definitions or missing endpoint documentation will produce less useful clients.