Skip to content

Consider support for Portkey AI as an LLM provider #363

Closed

Description

@maciekbanas

Through Portkey AI an organization may connect to different LLM providers (e.g. Azure, AWS, etc.).

https://portkey.ai/

User can chat with LLMs through Portkey AI via the endpoint chat/completions.

To connect we would need to pass:

  • our base_url (by default: "https://api.portkey.ai/v1")
  • a model,
  • Portkey API Keys (key to actual provider),
  • Virtual key (specific to Portkey, acts as an alias for actual API keys) - I think this may be optional,
  • prompts.

Wrote in httr2 simple PoC request:

llm_model <- "anthropic.claude-3-5-sonnet-20240620-v1:0"

request_body <- list(
        model = llm_model,
        messages = list(
          list(role = "system", content = system_prompt),
          list(role = "user", content = user_prompt)
        )
      )

httr2::request(base_url) |>
        httr2::req_method("POST") |>
        httr2::req_headers(
          `Content-Type` = "application/json",
          `x-portkey-api-key` = Sys.getenv("PORTKEY_API_KEY"),
          `x-portkey-virtual-key` = Sys.getenv("VIRTUAL_KEY")
        ) |>
        httr2::req_url_path_append("chat") |>
        httr2::req_url_path_append("completions") |>
        httr2::req_body_json(request_body) |>
        httr2::req_perform()

FYI @kalimu

We could prepare a PR, if it makes sense for you.

Activity

  1. hadley commented on Mar 28, 2025

    @hadley
    Member

    Yeah, a PR would be great if you're interested!

  2. shajoezhu commented on Apr 23, 2025

    @shajoezhu

    I would like to upvote this as well. Thanks @maciekbanas @hadley

  3. added a commit that references this issue on May 15, 2025
    ba2f46f
  4. shajoezhu commented on May 16, 2025

    @shajoezhu

    Thank you so much @hadley @maciekbanas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions