Portkey provides a robust and secure gateway to facilitate the integration of various Large Language Models (LLMs) into your applications, including your locally hosted models through LocalAI.
First, ensure that your API is externally accessible. If you’re running the API on http://localhost
, consider using a tool like ngrok
to create a public URL. Then, instantiate the Portkey client by adding your LocalAI URL (along with the version identifier) to the customHost
property, and add the provider name as openai
.
Note: Don’t forget to include the version identifier (e.g., /v1
) in the customHost
URL
Portkey currently supports all endpoints that adhere to the OpenAI specification. This means, you can access and observe any of your LocalAI models that are exposed through OpenAI-compliant routes.
List of supported endpoints here.
Use the Portkey SDK to invoke chat completions from your LocalAI model, just as you would with any other provider.
Virtual Keys serve as Portkey’s unified authentication system for all LLM interactions, simplifying the use of multiple providers and Portkey features within your application. For self-hosted LLMs, you can configure custom authentication requirements including authorization keys, bearer tokens, or any other headers needed to access your model:
OpenAI
)Custom Host
fieldYou can now use this virtual key in your requests:
For more information about managing self-hosted LLMs with Portkey, see Bring Your Own LLM.
Endpoint | Resource |
---|---|
/chat/completions (Chat, Vision, Tools support) | Doc |
/images/generations | Doc |
/embeddings | Doc |
/audio/transcriptions | Doc |
Explore the complete list of features supported in the SDK:
You’ll find more information in the relevant sections: