Packages

Elixir SDK for Bifrost, the LLM gateway by Maxim

Current section

Files

Jump to
ex_bifrost lib ex_bifrost api ocr.ex
Raw

lib/ex_bifrost/api/ocr.ex

# NOTE: This file is auto generated by OpenAPI Generator 7.23.0 (https://openapi-generator.tech)
# using the Elixir SDK Generator template (https://github.com/houllette/elixir-sdk-generator).
# Do not edit this file manually — edit the templates and regenerate instead.
defmodule ExBifrost.Api.OCR do
@moduledoc """
API calls for all endpoints tagged `OCR`.
"""
alias ExBifrost.Connection
import ExBifrost.RequestBuilder
@doc """
Perform OCR
Extracts text and content from documents or images using optical character recognition. Supports PDF URLs, base64-encoded documents, and image URLs.
### Parameters
- `connection` (ExBifrost.Connection): Connection to server
- `ocr_request` (OcrRequest):
- `opts` (keyword): Optional parameters
### Returns
- `{:ok, ExBifrost.Model.OcrResponse.t}` on success
- `{:error, Tesla.Env.t}` on failure
"""
@spec perform_ocr(Tesla.Env.client(), ExBifrost.Model.OcrRequest.t(), keyword()) ::
{:ok, ExBifrost.Model.BifrostError.t()} | {:ok, ExBifrost.Model.OcrResponse.t()} | {:error, Tesla.Env.t()}
def perform_ocr(connection, ocr_request, _opts \\ []) do
request =
%{}
|> method(:post)
|> url("/v1/ocr")
|> add_param(:body, :body, ocr_request)
|> Enum.into([])
connection
|> Connection.request(request)
|> evaluate_response([
{200, ExBifrost.Model.OcrResponse},
{400, ExBifrost.Model.BifrostError},
{500, ExBifrost.Model.BifrostError}
])
end
end