mandar1045

mandar1045

Hey everyone,

I’ve been working on something for the past while and finally published it, so I wanted to share.

It’s called Infusion. You give it an OpenAPI spec and it writes a full Elixir SDK for that API. Structs for every schema, a function for every endpoint, retries, streaming, pagination, the whole thing.

The reason I started: almost every API company now generates their SDKs with Stainless, Fern or Speakeasy, and none of them do Elixir. So every time a new API comes out, Python and TypeScript folks get an official SDK on launch day and we’re left writing HTTP calls by hand or hoping someone keeps a community client alive. I tried the two Elixir generators that already exist on OpenAI’s spec first. One crashed, and the other only worked after I forced it, and it turned union types into empty structs. So I built my own.

Using it looks like this. Add it as a dev dependency:

{:infusion, "~> 0.1", only: :dev, runtime: false}

and point it at a spec:

mix infusion.gen https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json --name GitHub

That’s the entire GitHub API, about 1,300 endpoints, in 16 seconds. What comes out is a normal Mix project you can read through:

And these are real calls to GitHub through it:

The repo comes back as a proper struct. The 404 at the bottom is on purpose, I asked for a repo that doesn’t exist, just to show what errors look like. You get one error struct with a type you can match on, like :not_found or :rate_limit, plus GitHub’s request ID.

Pagination was the fun part. Specs never say how an API pages its results, so Infusion looks at each endpoint and works it out. Cursors, page numbers, GitHub’s Link header, next-page URLs, it handles all of them. Every list endpoint gets an _all function that gives you a lazy stream, and pages only load as you read:

Streaming works too. Endpoints that send Server-Sent Events get a _stream function. This one is live Wikipedia edits coming in through an SDK generated from Wikimedia’s spec:

I’ve been testing it on OpenAI, Stripe, GitHub, Twilio and Cloudflare’s published specs. All five generate SDKs that compile without a single warning, and Cloudflare’s is huge (3,778 endpoints). GitHub and Wikimedia I’ve tested against the real APIs. The rest only against stubs so far, because I don’t have keys for everything.

There are two packages:

  • infusion is the generator you run: infusion | Hex
  • infusion_runtime is what every generated SDK runs on. It handles HTTP, retries, decoding and errors, and you never add it yourself: infusion_runtime | Hex

Splitting it that way keeps the generated code small, and a fix in the runtime reaches every SDK without regenerating anything.

It’s 0.1, so it’s rough in places. The function names come straight from the spec, so some of them are clunky. You can see it in the Wikimedia screenshot, get_v2_mediawiki_recentchange_stream is not a name anyone would pick. Fixing names is what I’m working on next. Objects that a spec defines inline still come back as plain maps, and there’s no config file yet, so for GitHub you have to set auth: :bearer in your config yourself.

If you try it on a spec you use and something breaks, please open an issue with the spec attached. That helps me more than anything. I’d also love to know which API you’d want an SDK published for first. I’m leaning towards GitHub.

Code is here:

Docs: infusion v0.2.0 — Documentation

Thanks for reading.

Showing Posts 1 to 2

gtcode

gtcode

Great work, Mandar. Gave Infusion a star and forked it. I built Pristine, which tackles some of the same problems but from a different perspective. One thing worth checking out is how mine separates the execution pipeline from the generated SDKs, including pluggable transports, retry budgets, rate limiters, circuit breakers, cancellation, and provider-specific policies. I also created a provider testkit for checking generated code consistency and detecting drift. Yours does a better job with OpenAPI ingestion and SDK ergonomics. I’m way behind on my own open source work, and I’m happy to see you take your creation further.

mandar1045

mandar1045 OP

Thanks, really appreciate it, I’ll check out Pristine. The pipeline split and the drift testing sound like things I want in Infusion too.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

mandar1045
I’ve published twilio, an SDK for Twilio’s core REST API (2010-04-01): messages, calls, phone numbers, recordings, conferences, usage and...
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
kip
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
danschultzer
I’ve moved the strategies out of PowAssent and created a multi-provider framework for Elixir. This way the strategies can be used in any ...
New

Other Trending Topics Top

dominicletz
Hey there, I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first. ...
New
raa-ziq
Hi everyone :waving_hand: I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
AstonJ
With advancements in AI gathering pace and set to increasingly accelerate, perhaps it’s worth having an annual thread on the topic - feel...
New
bartblast
If you haven’t tried Hologram yet, what’s stopped you? Here’s why I’m asking. Building a framework turns out to be two jobs, the framewo...
New
mat-hek
Popcorn, the library that runs Elixir code in the browser, is now stable :popcorn: This is possible because it now builds on a very stab...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews