OpenRouterAPI
Documentation for OpenRouterAPI.
OpenRouterAPI.chat_completions
— Methodchat_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.
OpenRouterAPI.encoded_image_url
— Methodencoded_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.
OpenRouterAPI.encoded_pdf_url
— Methodencoded_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.
OpenRouterAPI.get_all_models
— Methodget_all_models()
Retrieves a list of available models from the OpenRouter API.
Returns
- A list of available models.
OpenRouterAPI.get_credits
— Methodget_credits()
Retrieves the credit balance for the authenticated user.
Returns
- The credit balance.
OpenRouterAPI.get_meta_key
— Methodget_meta_key()
Retrieves information about the current API key.
Returns
- Information about the current API key.
OpenRouterAPI.text_completion
— Methodtext_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.
OpenRouterAPI.APIClient.ChatCompletionsRequest
— TypechatCompletions_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
OpenRouterAPI.APIClient.FunctionDescription
— TypeFunctionDescription Function Description
FunctionDescription(;
description=nothing,
name=nothing,
parameters=nothing,
)
- description::String
- name::String
- parameters::Any
OpenRouterAPI.APIClient.Message
— TypeMessage DefaultMessage
Message(;
role=nothing,
content=nothing,
)
- role::String
- content::MessageContent
OpenRouterAPI.APIClient.MessageContent
— TypeMessage_content
MessageContent(; value=nothing)
OpenRouterAPI.APIClient.Part
— TypePart
Part(;
type=nothing,
text=nothing,
image_url=nothing,
file=nothing,
)
- type::String
- text::String
- image_url::PartImageUrl
- file::PartFile
OpenRouterAPI.APIClient.PartFile
— TypePart_file
PartFile(;
filename=nothing,
file_data=nothing,
)
- filename::String
- file_data::String
OpenRouterAPI.APIClient.PartImageUrl
— TypePartimageurl
PartImageUrl(;
url=nothing,
)
- url::String
OpenRouterAPI.APIClient.ResponseFormat
— TypeResponse_format response format Description
ResponseFormat(;
type=nothing,
json_schema=nothing,
)
- type::String
- json_schema::ResponseFormatJsonSchema
OpenRouterAPI.APIClient.ResponseFormatJsonSchema
— TypeResponseformatjson_schema
ResponseFormatJsonSchema(;
name=nothing,
strict=true,
schema=nothing,
)
- name::String
- strict::Bool
- schema::Any
OpenRouterAPI.APIClient.TextCompletionRequest
— TypetextCompletion_request
TextCompletionRequest(;
model=nothing,
prompt=nothing,
)
- model::String
- prompt::String
OpenRouterAPI.APIClient.Tool
— TypeTool Tool Description
Tool(;
type=nothing,
var"function"=nothing,
)
- type::String
- var"function"::FunctionDescription
OpenRouterAPI.APIClient.ToolChoice
— TypeToolChoice ToolChoice
ToolChoice(; value=nothing)
OpenRouterAPI.APIClient.ToolChoiceAnyOf
— TypeToolChoice_anyOf
ToolChoiceAnyOf(;
type=nothing,
var"function"=nothing,
)
- type::String
- var"function"::ToolChoiceAnyOfFunction
OpenRouterAPI.APIClient.ToolChoiceAnyOfFunction
— TypeToolChoiceanyOffunction
ToolChoiceAnyOfFunction(;
name=nothing,
)
- name::String
OpenRouterAPI.APIClient.basepath
— MethodThe default API base path for APIs in DefaultApi
. This can be used to construct the OpenAPI.Clients.Client
instance.
OpenRouterAPI.APIClient.chat_completions
— Methodchat/completions
chat/completions
Params:
- chatcompletionsrequest::ChatCompletionsRequest
Return: Any, OpenAPI.Clients.ApiResponse
OpenRouterAPI.APIClient.get_credits
— MethodGet credits
Returns the total credits purchased and used for the authenticated user
Params:
Return: Any, OpenAPI.Clients.ApiResponse
OpenRouterAPI.APIClient.get_current_key
— MethodGet current API key
Get information on the API key associated with the current authentication session
Params:
Return: Any, OpenAPI.Clients.ApiResponse
OpenRouterAPI.APIClient.get_models
— MethodList available models
Returns a list of models available through the API
Params:
Return: Any, OpenAPI.Clients.ApiResponse
OpenRouterAPI.APIClient.text_completion
— Method/completions
Send a completion request to a selected model (text-only format)
Params:
- textcompletionrequest::TextCompletionRequest
Return: Any, OpenAPI.Clients.ApiResponse