dspy icon indicating copy to clipboard operation
dspy copied to clipboard

[Feature] Google GenAI SDK

Open TheMellyBee opened this issue 9 months ago • 3 comments

What feature would you like to see?

Google has released a unified SDK for both Gemini and Vertex AI that has the newest models. I'm currently evaluating frameworks to move forward with, and we'd love to get going with DSPy. However this LLM is critical for us.

https://googleapis.github.io/python-genai/

Would you like to contribute?

  • [ ] Yes, I'd like to help implement this.
  • [ ] No, I just want to request it.

Additional Context

No response

TheMellyBee avatar Mar 17 '25 16:03 TheMellyBee

I'm flexible and happy to help. However I'm also low on time.

TheMellyBee avatar Mar 17 '25 16:03 TheMellyBee

Hi @TheMellyBee , thanks for raising this!

DSPy LM queries go through LiteLLM, which does support both Gemini and VertexAI in their providers (saw some example snippets here).

Does the newly-released SDK require a different provider? Raising this with LiteLLM would be the best way to integrate with DSPy!

arnavsinghvi11 avatar Mar 17 '25 17:03 arnavsinghvi11

It does! This is a new unified API that will allow API keys from either of those. It also cleaned things up quite a bit. Moving forward they will be removing support for the other SDK. I've gone ahead and requested this feature with LiteLLM

TheMellyBee avatar Mar 17 '25 17:03 TheMellyBee

You can also subclass from dspy.BaseLM to make your own LM that under the hood uses google-genai: https://github.com/stanfordnlp/dspy/blob/6ee8cdca4bf3283a8bde6b92c628cbbd0851fe9b/dspy/clients/base_lm.py#L28

chenmoneygithub avatar Apr 26 '25 00:04 chenmoneygithub