Custom API Endpoints (OpenAI Compatible)

1. The problem

Limited to Gemini API and OpenAI.

2. Simple solution

Just allow adding our own endpoint url so we can use OpenRouter, Groq, Mixtral, local llms.

They can be OpenAI Compatible, so it only changes the endpoint, no code changes are required.

3. Screenshot examples

Screenshot taken from GPT-Pilot.

OpenAI: https://api.openai.com/v1/chat/completions
OpenRouter: https://openrouter.ai/api/v1/chat/completions
LiteLLM: http://0.0.0.0:4000/v1/chat/completions

Oh I like this, especially if all you need to change is the end point.

Yep. that’s all I need :slight_smile:

I’m using Ollama combined with LiteLLM Proxy to run local open-source models. 7b is the max I can run on my machine but that’s good enough for testing.

image

Adding openAI url textbox to change the api url service point

Adding another openAI slot called ‘alt 1’ for now

Allows you to keep original openAI instead of replacing the url for more options

1 Like

Feature is complete and ready for testing!

Works perfectly. Love it <3

POST /v1/chat/completions

{
    "max_tokens": null,
    "model": "openhermes",
    "messages": [
        {
            "role": "user",
            "content": "Use html tags like <p> <h2> <li>. Write an article for honey dishes a beginner’s guide to cooking with honey honey recipe chicken sweet recipes"
        }
    ]
}

200 OK

{
    "id": "chatcmpl-262",
    "object": "chat.completion",
    "created": 1712910563,
    "model": "openhermes",
    "system_fingerprint": "fp_ollama",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n\t<meta charset=\"UTF-8\">\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n\t<title>A Beginner's Guide to Cooking with Honey</title>\n</head>\n<body>\n\t<h2>Honey Dishes: A Beginner's Guide to Cooking with Honey</h2>\n\t<p>Honey is an incredibly versatile ingredient that can add a unique sweetness and depth of flavor to a wide variety of dishes. Whether you're a beginner in the kitchen or an experienced chef, incorporating honey into your cooking repertoire can elevate your meals to new heights. In this guide, we'll explore some basic tips for working with honey, as well as a few delicious honey recipe ideas to get you started.</p>\n\t<h2>Using Honey in the Kitchen</h2>\n\t<ol>\n\t\t<li>Choose the right type of honey: There are many different types of honey available, each with its own unique flavor profile. Experiment with different varieties to find the ones you like best.</li>\n\t\t<li>Measure honey accurately: Honey is sticky and can be difficult to measure accurately. To avoid messes, lightly spray your measuring spoon or cup with cooking spray before adding the honey. This will make it easier to remove the honey without leaving any behind in the container.</li>\n\t\t<li>Substitute honey for sugar: Honey is an excellent natural sweetener that can be used as a substitute for white sugar in many recipes. For every cup of sugar called for in a recipe, you can typically use 3/4 cup of honey instead.</li>\n\t</ol>\n\t<h2>Sweet Recipes with Honey</h2>\n\t<p>Here are a few delicious honey recipe ideas to inspire your culinary adventures:</p>\n\t<ul>\n\t\t<li><strong>Honey-glazed chicken:</strong> This simple yet flavorful dish features chicken breasts coated in a mixture of honey, soy sauce, garlic, and ginger. Bake or grill the chicken until it's cooked through and tender, then serve it with a side of your choice.</li>\n\t\t<li><strong>Sweet honey recipes:</strong> Honey is a natural companion to many fruits, making it an ideal ingredient for sweet dishes like honey-glazed carrots or a honey-pear crisp. The possibilities are endless – experiment with different fruit combinations and seasonings to find your favorite.</li>\n\t</ul>\n</body>\n</html>"
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 50,
        "completion_tokens": 603,
        "total_tokens": 653
    }
}

Just a Quality-of-Life suggestion, someone might accidently remove the openai’s endpoint since that is editable too, so just mentioning it somewhere might be a good idea.

image

Reset to default url added!

Thankyou

Since Ollama and LM Studio getting a lot of exposure, would like to suggest to create a youtube tutorial video for setting up local AI x SCM :ok_hand:

1 Like

Ok will put it on the todo list

1 Like

Tutorial video done!

Let me know any other videos you want to see

1 Like