OpenRouterAPI

Documentation for OpenRouterAPI.

OpenRouterAPI.chat_completionsMethod
chat_completions(request::ChatCompletionsRequest; verbose::Bool=false)

Sends a chat completion request to the OpenRouter API.

Arguments

  • request::ChatCompletionsRequest: The chat completion request object.
  • verbose::Bool: (optional) If true, returns the full API response. Defaults to false.

Returns

  • The chat completion response, or the full API response if verbose is true.
source
OpenRouterAPI.encoded_image_urlMethod
encoded_image_url(img_path::String)

Encodes an image file to a base64 data URL.

Arguments

  • img_path::String: The path to the image file.

Returns

  • A base64 data URL representing the encoded image.
source
OpenRouterAPI.encoded_pdf_urlMethod
encoded_pdf_url(pdf_path::String)

Encodes a PDF file to a base64 data URL.

Arguments

  • pdf_path::String: The path to the PDF file.

Returns

  • A base64 data URL representing the encoded PDF.
source
OpenRouterAPI.text_completionMethod
text_completion(request::TextCompletionRequest; verbose::Bool=false)

Sends a text completion request to the OpenRouter API.

Arguments

  • request::TextCompletionRequest: The text completion request object.
  • verbose::Bool: (optional) If true, returns the full API response. Defaults to false.

Returns

  • The completed text, or the full API response if verbose is true.
source
OpenRouterAPI.APIClient.ChatCompletionsRequestType

chatCompletions_request

ChatCompletionsRequest(;
    model=nothing,
    messages=nothing,
    tools=nothing,
    tool_choice=nothing,
    response_format=nothing,
)

- model::String
- messages::Vector{Message}
- tools::Vector{Tool}
- tool_choice::ToolChoice
- response_format::ResponseFormat
source
OpenRouterAPI.APIClient.PartType

Part

Part(;
    type=nothing,
    text=nothing,
    image_url=nothing,
    file=nothing,
)

- type::String
- text::String
- image_url::PartImageUrl
- file::PartFile
source