-module(gopenai@client). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([new/0, endpoint_to_str/1]). -export_type([client/0, endpoint/0]). -type client() :: {client, binary(), binary()}. -type endpoint() :: completions | embeddings. -spec new() -> client(). new() -> Endpoint = <<"https://api.openai.com"/utf8>>, dot_env:load(), _assert_subject = dot_env_ffi:get_env(<<"OPENAI_API_KEY"/utf8>>), {ok, Api_key} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"gopenai/client"/utf8>>, function => <<"new"/utf8>>, line => 11}) end, {client, Endpoint, Api_key}. -spec endpoint_to_str(endpoint()) -> binary(). endpoint_to_str(Endpoint) -> case Endpoint of completions -> <<"chat/completions"/utf8>>; embeddings -> <<"embeddings"/utf8>> end.