restlessronin

restlessronin

Openai_ex - OpenAI API client library

The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API.

Docs are at OpenaiEx User Guide — openai_ex v0.9.18.

Changelog

The main user guide is a livebook, so you should be able to run everything without any setup. The user guide is also the test suite. It is run before every version release, so it is always up to date with the library.

Portions of this project were developed with assistance from ChatGPT 3.5 and 4, as well as Claude 3 Opus and Claude 3.5 Sonnet. However, every line of code is human curated (by me :innocent:).

All API endpoints and features (as of Mar 16, 2025) are supported, including the most recent Responses API (proposed replacement for Chat Completion).

Configuration of Finch pools and API base url are supported.

There are some differences compared to other elixir openai wrappers.

  • I tried to faithfully mirror the naming/structure of the official python api. For example, content that is already in memory can be uploaded as part of a request, it doesn’t have to be read from a file at a local path.

  • I was developing for a livebook use-case, so I don’t have any config, only environment variables.

  • Streaming API versions, with request cancellation, are supported.

  • The underlying transport is finch, rather than httpoison

  • 3rd Party (including local) LLMs with an OpenAI proxy, as well as the Azure OpenAI API, are considered legitimate use cases.

Documentation is still a work in progress. In addition to the user guide, there are also Livebook examples for

The library is developed in a livebook docker image running in a VS code dev container.

Please try it out and let me know what you think. Happy to receive suggestions (and PRs) for improvement, as well as illustrative sample notebooks.

Most Liked

restlessronin

restlessronin

I have just published v0.4.0 with all the new and updated API features announced at the OpenAI DevDay.

In particular the beta Assistants API is implemented, although examples have not as yet made it into the user guide and the documentation is incomplete in places. I hope to have some examples soon, and perhaps more complete documentation as the beta stabilizes.

In addition the deprecated ‘function’ calls parameters in the chat completion api have been replaced with the new ‘tool’ based parameters (shoutout to @TomBers for doing that and helping out with the documentation and testing, and generally being on the ball).

Enjoy playing with the new functionality!

restlessronin

restlessronin

No deep reason. I liked the Req design a little better, but it doesn’t support multi part form uploads. Tesla does. And some of the API endpoints require it.

hubertlepicki

hubertlepicki

FYR, there’s a stand-alone multipart building library that can be used with HTTP clients that don’t have it built in, at least one, I think I used a different one back in the day but can’t find it now:

neilberkman

neilberkman

In case it’s helpful to anyone, I contributed a streaming ChatGPT example to wojtekmach/mix_install_examples here.

restlessronin

restlessronin

Just published. v0.1.9 - File uploads from local paths are now streamed.

Where Next?

Popular in Announcing Top

mspanc
I am pleased to announce an initial release of the Membrane Framework - an Elixir-based framework with special focus on processing multim...
New
fteschke
Announcing: playwright_ex A simple Elixir client for the Playwright node.js server. Automate browsers like Chromium, Firefox, Safari an...
New
metehan
exterm_ai runs a real PTY in Elixir and exposes it in the browser using xterm.js. Previously I shared exterm library without AI this one ...
#ai
New
roriholm
Hi! I just wanted to share my public release of something I’ve been working on. The Paradigm library provides some core utilities for a d...
New
garrison
Hobbes is a scalable, fault-tolerant transactional record store written in Elixir. Hobbes is designed to be: Scalable - Hobbes can sha...
New
jsm
Once is an Ecto type for locally unique 64-bits IDs generated by multiple Elixir nodes. Locally unique IDs make it easier to keep things ...
New
Mati365
Phoenix has great tooling overall, but one thing that’s still lacking is a solid, plug-and-play integration with a modern WYSIWYG editor....
New
mudspot
Hi folks, I’d like to announce the release of Prometheus Agents, a set of subagents for Claude Code that cater to the Elixir Phoenix pro...
New
volcov
Hello, How is everyone? I hope you’re well =) I worked on a project with some legacy code that existed before Oban’s arrival. This leg...
New
rodloboz
Sifter is a a query filtering library for Ecto. It lets frontend apps send human-readable query strings like: "elixir phoenix status:pu...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement