goose icon indicating copy to clipboard operation
goose copied to clipboard

Generic Open AI API compatible provider. (Deepseek, Helicone, LiteLLM etc)

Open 242816 opened this issue 10 months ago • 17 comments

Most inference providers support the Open AI API.

So this morning I wanted to use Helicone to track goose calls.

With Aider I would use this https://aider.chat/docs/llms/openai-compat.html

I tried to use the existing open ai provider https://github.com/block/goose/blob/main/crates/goose/src/providers/openai.rs

This didn't work as it's too tied into Open AI.

So a generic provider should allow me to set the HOST, MODEL and KEY to any provider I want.

Requirements

A new provider with the ability to set the following

OPENAI_API_BASE= OPENAI_API_KEY= OPENAI_API_MODEL=

Note the BASE needs to be everything up to the /v1 i.e. https://oai.helicione.ai/324324-234234-24324/v1

242816 avatar Jan 29 '25 07:01 242816

Second this, I'm trying to use Perplexity AI which has Open AI compatible API keys, but I'm not able to configure it

willemsFEB avatar Jan 29 '25 08:01 willemsFEB

you can set export GOOST_HOST=... in ~/.zshrc for now, until the UI has support for it. Also hard to know how well things support the openai api (can't just be chat)

michaelneale avatar Jan 29 '25 08:01 michaelneale

@willemsFEB @242816 would it make sense to have openai, but then a seperate "openai compatible" provider (seperate choices?) - the latter will ask for more config, thoughts?

michaelneale avatar Jan 29 '25 09:01 michaelneale

That makes sense, you may also want to add things like azure api version there as an optional parang

digitalbuddha avatar Jan 29 '25 11:01 digitalbuddha

+1 for openai like compatible provider in UI

dailydaniel avatar Jan 29 '25 12:01 dailydaniel

+1 for openai compatible API. I think it would make more sense to have separate configurations for openai and openai-compatible APIs. This way, you can have more control over the API version of the OpenAI-compatible provider, which may be necessary to work around edge cases of mismatching API versions.

gzuuus avatar Jan 29 '25 12:01 gzuuus

+1 for openai like compatible provider in UI 🙏

VonLuderitz avatar Jan 29 '25 13:01 VonLuderitz

+1 for openai like compatible provider in UI. Our institution is starting to evaluate LiteLLM, which uses an openai compatible api with its own API Key. This will likely become more prevalent as businesses like LiteLLM spring up to offer cloud and on-prem ways to host opesource models.

dmlond avatar Jan 29 '25 13:01 dmlond

@michaelneale thanks for the suggestion, so I've set OPENAI_HOST=https://api.perplexity.ai (you mention GOOST_HOST but that wouldn't that be for Google Gemini API?)

I'm able to get further, however, now goose is appending v1/chat/completions to the end of the URL, which is invalid for Perplexity, as it's expects https://api.perplexity.ai/chat/completions, so without the v1

Any suggestions how I can bypass this?

willemsFEB avatar Jan 30 '25 08:01 willemsFEB

not at the moment - will need to enhance things to have that more generic thing (which I think is a good idea) - if you are able to - can clone and run just run-ui - you could temporarily change the openai.rs to do what you want to see how it works in the meantime

michaelneale avatar Feb 01 '25 00:02 michaelneale

Is it possible to get goose to add this feature?

A prompt something like...

Using the existing `crates/goose/src/providers/openai.rs` 
create a new provider called `openai_compatible.rs`. 

This should have the following features.

- a env OPENAI_API_BASE which sets the base URL.
- OPENAI_API_KEY which is passed in a a Bearer
- OPENAI_API_MODEL which will hold the model name.

Or is it more complex than that?

242816 avatar Feb 01 '25 16:02 242816

Yeah @242816 that should work as long as the host supports all the openai features including tools. Contribution welcome but we will get started on this soon if no one from this thread has tried it out yet.

baxen avatar Feb 07 '25 05:02 baxen

there seems to be a lot of interest in providing an Open-AI compatible provider 🙌🏼 if anyone is interested, this would be a great contribution. or else, we will hopefully get to this in a couple weeks and update here. https://github.com/block/goose/blob/main/CONTRIBUTING.md

it should be similar to these providers:

  • https://github.com/block/goose/blob/main/crates/goose/src/providers/openai.rs
  • https://github.com/block/goose/blob/main/crates/goose/src/providers/groq.rs

salman1993 avatar Feb 10 '25 14:02 salman1993

Great, can't wait to use Goose with LM Studio. :)

gitcakes avatar Feb 13 '25 22:02 gitcakes

I definitely want to use Helicone to observe and iterate on goose's LLM interactions. I think this is required for that to happen, but if there's another way to change host and set an extra header, do let me know!

crabsinger avatar Feb 14 '25 18:02 crabsinger

Since Goose does not support LM-studio as an LLM provider I built an Ollama proxy to convert your queries to OpenAI. Its working on MLX models too.

Check it out, hope it helps! https://github.com/Embedded-Nature/ollama-proxy/

ICeZer0 avatar Feb 16 '25 01:02 ICeZer0

fwiw - I added mlx-lm as a provider. it's barebones but it works.

https://github.com/fblissjr/goose-mlx

goose configure & session:

Image

mlx_lm.server log:

Image

fblissjr avatar Feb 21 '25 21:02 fblissjr

Also here for the LM Studio support. 🙂

And ++ thanks to @ICeZer0 for the interim workaround through Ollama! Been wanting to have better flexibility around using models downloaded between the two as well, so this helps with that too! 😀

spong avatar Apr 10 '25 20:04 spong

I think we've got this working! Please feel free to reopen if not https://block.github.io/goose/docs/getting-started/providers#using-custom-openai-endpoints

baxen avatar Jun 17 '25 05:06 baxen

I am getting errors when trying to use this with deepinfra

Image

armstrys avatar Jun 24 '25 03:06 armstrys

I don't think the behavior matches the guide. In the guide, for Desktop, it says "Click Edit, enter your API key, and click Set as Active."

However, setting the API key here has no effect if you already have OPENAI_API_KEY set in your ~/.zshrc, and it is set to your actual OpenAI API key, rather than the generic compatible provider (e.g LiteLLM)

There is a complicated workaround, reported here:

  • #2507

cmungall avatar Jun 29 '25 02:06 cmungall

Does not work on LMstudio, come on most popular LLM streaming app and not supported.

akierum avatar Aug 28 '25 01:08 akierum