Hey API Integration
Hey API can be integrated with oRPC in two ways, depending on what you start with:
- Generate an oRPC contract from an existing OpenAPI specification.
- Convert an existing Hey API generated client directly into an oRPC client.
WARNING
The Hey API integration is still unstable. As Hey API continues to evolve, this integration may introduce breaking changes in the future.
Convert OpenAPI to an oRPC Contract
If you already have an OpenAPI specification, you can use Hey API to generate an oRPC contract. See OpenAPI to Contract for the complete setup and next steps.
Once generated, you can use the contract to:
- Implement the contract on your own server with Implement Contract.
- Create a type-safe client with OpenAPILink.
- Use the generated contract as a reference alongside Define Contract to better understand its structure.
Convert a Hey API Client Directly to an oRPC Client
If you already have a generated Hey API client and want to use it as an oRPC client without generating a contract first, use toORPCClient.
import { experimental_toORPCClient } from '@orpc/hey-api'
import * as sdk from 'src/client/sdk.gen'
export const client = experimental_toORPCClient(sdk)
const { body } = await client.listPlanets()This client behaves like any standard oRPC server-side client or client-side client, so you can use it with any oRPC-compatible library.
Error Handling
Internally, oRPC passes the throwOnError option to the Hey API client. If the original Hey API client throws an error, oRPC forwards it as is, ensuring consistent error handling.

