Urgent.News

What's breaking now, across thousands of outlets.

Tech

How to Configure a Custom LLM Proxy in OpenOPC (and Debug LiteLLM)

(If you missed it, check out my previous post on Getting Started with OpenOPC to see why I'm using this agent framework in the first place!) I recently started setting up OpenOPC to run my AI agents. To save on API costs, I decided to hook it up to a custom, OpenAI-compatible proxy at https://api.freetheai.xyz/v1 . I expected it to be a simple drop-in replacement. In other platforms, you just set…

To configure a custom LLM proxy in OpenOPC, one must first set the desired model in the .opc/config/llm_config.yaml file. Initially, the model was set as glm/glm-5.2. However, when OpenOPC attempted to run the agents, LiteLLM crashed with an error stating that the LLM provider was not provided. This was because LiteLLM requires the LLM provider to be specified explicitly.

OpenAI has a convention of prefixing model names with "openai/", which LiteLLM didn't recognize when using a custom api_base. To resolve this issue, the model string in the config had to be updated to openai/glm-5.2. This adjustment allowed LiteLLM to format the request correctly. However, another error occurred when LiteLLM stripped off the openai/ prefix before sending the request to the proxy, resulting in the model name glm-5.2 being passed directly to the proxy, which wasn't recognized.

The solution was to modify the config by stacking the OpenAI prefix with the actual model name: llm: default_model: openai/glm/glm-5.2. This configuration ensured that LiteLLM used the OpenAI API format while passing the correct model name glm/glm-5.2 to the proxy. Upon restarting OpenOPC with this configuration, the routing worked as expected.

It's crucial to note that when connecting OpenOPC to a custom proxy, one should query the proxy's models endpoint first to retrieve the literal string it expects. This string should then be prefixed with openai/ in the OpenOPC config. Despite facing a temporary ServiceUnavailableError due to high proxy server capacity, the connection and routing were ultimately successful.

For those managing custom API proxies and model routing in their agent stacks, the key considerations are whether to configure prefixes like this in LiteLLM or to rewrite the requests at the proxy level before they reach the models. Sharing experiences and preferences on this topic can be beneficial for the community.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Notion meeting notes on Linux systems

Olá! tl;dr: Notion web não captura output de áudio da sua máquina. Para contornar isso criei um sink vazio, atrelei output e input de áudio nele e disponibilizei-o através de um mic virtual.

More from Tuesday 4 August →