https://www.boundaryml.com logo
🟡 Using BAML in Elixir with OpenAPI and Custom Cl...
# questions
k
Hi, I am trying to use BAML in Elixir. I need to be able to pass my custom client registry, since I use an LLM proxy and need custom additional header, and this is not currently possible with
baml_elixir
, that's why I am considering OpenAPI option. So my first questions is, is it possible to do the OpenAPI spec generation from BAML and then Elixir code generation from OpenAPI as a separate step (compile/build time) from the Rest API serving? In other words, I want to generate the Elixir modules from BAML during build time, and then only serve the Rest API in the runtime.
g
Hello! Yes, what I think you're describing is the normal OpenAPI client setup. You edit your BAML code, regenerate the open-api spec, regenerate the elixer client from the open-api spec, and the BAML server (which has been watching your .baml files for changes) updates to be able to handle the new input/output schemas.
In fact in your generators.baml file (if you have the same file structure from when you ran
baml-init
, if you use the openapi generator, this is an field you can use that will re-run an arbitrary command every time any .baml file updates. It's common to use this field to drive the openapi-cli. That way you get new elixer client code every time you change your .baml files.
k
Thanks for responding @greg (BAML)! I just realized I missed the very first section in the docs where it describes
baml-cli
, which has exactly what I need, separate commands for
generate
and
serve
.
My other question is, does the rest generator not support the stream routes? I see that when serving the rest API it actually does support
/stream
routes, but those are not being generated in the OpenAPI spec, or am I missing something?
g
That's correct. OpenAPI doesn't natively support streaming, so we can't generate streaming clients, although the streaming endpoints are available from the server.
e
@kirakos6970 passing the full client registry is now supported in the latest baml_elixir version 🙂
g
That's awesome news, @User !!!