API strategy
Platform integration
TypeSpec vs OpenAPI compared: how each works, where TypeSpec's compilation model wins, when hand-authored OpenAPI still fits, and what agents change.

You're deciding how to define your APIs. The choice used to be OpenAPI or hand-written docs. Now there's a third option gaining ground: TypeSpec, Microsoft's API definition language that compiles down to OpenAPI, JSON Schema, or Protobuf (which in turn feeds gRPC toolchains).
This piece is for platform engineers, API architects, and heads of engineering picking a specification approach for a new API — or reconsidering an existing one because AI agents are now consuming the spec, not just human developers.
The short version: OpenAPI is the interchange format the ecosystem runs on. TypeSpec is a higher-level authoring language that generates OpenAPI (and other outputs) from more concise, reusable source. They're not really competitors — one produces the other. The real question is where in your workflow the source of truth lives, and how much your team writes by hand.
OpenAPI is a specification format for describing HTTP APIs. You write a YAML or JSON document that declares your endpoints, request and response schemas, authentication, and error contracts. The current version is 3.2 (released September 2025), which builds on 3.1's alignment with JSON Schema 2020-12.
An OpenAPI document is the contract. The ecosystem around it is enormous: Swagger UI renders it as interactive docs, Redoc produces a different style of reference, openapi-generator and tools like Speakeasy and Fern generate SDKs, contract-testing tools like Prism mock the API, and validators like Spectral enforce house style. Every major HTTP framework has some way to emit or consume OpenAPI.
You write OpenAPI in one of two ways. Design-first: hand-author the YAML and generate server stubs and clients from it. Code-first: annotate your handlers and let the framework emit the spec at build time. Both approaches have real production users, and both have failure modes — hand-written specs drift from the code, generated specs inherit whatever inconsistencies the code has.
We've covered the OpenAPI ecosystem in depth in what is OpenAPI and OpenAPI specification best practices.
TypeSpec is a domain-specific language for describing API shape. You write .tsp files that look more like TypeScript than YAML — models, operations, decorators, namespaces. A compiler emits OpenAPI 3.0/3.1, JSON Schema 2020-12, or Protobuf from the same source.
Microsoft built TypeSpec (originally CADL) internally to manage the scale of Azure's API surface. Azure has 200+ services and thousands of operations, and hand-authoring OpenAPI for all of them produced inconsistency, duplication, and drift. TypeSpec's pitch is that you write the API shape once, in a language designed for it, and the machine produces the interchange formats.
A small TypeSpec example looks like this:
model Pet {
id: string;
name: string;
species: "cat" | "dog" | "bird";
}
@route("/pets")
interface Pets {
@get list(): Pet[];
@post create(@body pet: Pet): Pet;
}
Compile it and you get an OpenAPI document that would take three to four times the lines to write by hand. The library system lets you package common patterns — pagination, error envelopes, auth schemes — as reusable modules that enforce consistency across teams.
TypeSpec is open source, actively developed, and used in production by Azure. The ecosystem outside Microsoft is smaller but growing.
Stay with OpenAPI as your primary authoring surface when:
Reach for TypeSpec when:
$ref structures ossify. TypeSpec's model composition and inheritance handle this better.Both options produce OpenAPI in the end. But what they produce, and how much of your product surface it covers, matters more than the authoring format when agents are the consumer.
Agents don't read OpenAPI directly at runtime. They call tools, which are generated from the spec. If your OpenAPI describes 2% of what your product can actually do — because most product capability sits behind the UI, not the API — then TypeSpec vs OpenAPI is a rounding-error debate. The gap you need to close is between your API surface and your product surface, not between two ways of writing the API surface you already have.
The agent-relevant differences between the two:
additionalProperties, and un-annotated parameters produce tools the model can't call correctly. Both approaches can produce good specs — TypeSpec makes it slightly harder to produce a bad one.Both TypeSpec and OpenAPI assume the API surface is the interface. That assumption held when human developers were the consumers. For agents, it usually doesn't — the API surface is a small fraction of what the product does, and closing that gap by hand-writing more OpenAPI (or TypeSpec) is a multi-year project.
Pontil is a Tools-as-a-Service platform. We generate agent tools directly from your codebase, not just from your OpenAPI spec — which means the tools reach product capability that never made it into the API in the first place. Where you already have OpenAPI (however you authored it), we consume it. Where the capability lives only in the code, we scan for it. Either way, the tools stay current as the product changes, execute as the authenticated user, and honour the permissions the UI already enforces. Your spec choice becomes an input, not the ceiling.
For a new API being built from scratch by a team that also owns other services and cares about consistency across them: TypeSpec. The library model pays back within the first few APIs, and generating OpenAPI as a build artefact keeps the ecosystem tooling working.
For a single existing API where the spec is already reliable and the team ships OpenAPI without pain: stay on OpenAPI. The migration cost is real, and you'd be adding a compilation step to solve a problem you don't have.
For a platform with dozens of services and a governance problem: TypeSpec, and treat the library layer as the actual standardisation mechanism. Style guides are advisory; compiler errors are not.
The question isn't which format wins. It's whether your authoring pain is bad enough — and your API portfolio big enough — to justify adding a compilation step. If it is, TypeSpec is the strongest option in the space. If it isn't, OpenAPI is still the format the ecosystem runs on.
Stay up to date on the ever changing agentic landscape.