cookbook
cookbook copied to clipboard
OpenAPI files for AI Models
If you want to use a more advanced model with Agent Builder in GCP, then you need to generate an OpenAPI YAML or JSON file and upload it as a tool.
This is definitely something that people can do individually, but it would be beneficial to everyone if there were ready-made files and examples in the cookbook that people could grab quickly. I assume that there are copies of this floating around the Google-universe since I saw it often during Google Next, someone just needs to grab them and make them publicly available.
Is this request intended for the Vertex Gemini API? This cookbook covers the regular Gemini API, so I'm not sure that a guide here will help solve your problem but let me know if that's not correct.
@markmcd Yeah I wanted to use the regular Gemini API in this case: https://generativelanguage.googleapis.com/v1beta/models/{model}
I think this is the best repo to put the OpenAPI spec in since you already have the curl examples, but long-term it would be nice if it would show up in the docs as reference, but since the file can be dependent on the model it might be difficult to keep all of the different versions up to date on the site.
Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.
Do you want the complete OpenAPI spec for the whole Gemini API? Or are you looking for more correct, specific specs for models or use-cases?
The API itself has functionality that is restricted to specific models (e.g. candidate_count can only be 1 for the Gemini models, tuning only works on specific models, 1.0 pro doesn't support JSON, sysint, etc), and some endpoints only useful in specific cases (e.g. generateText for PaLM was superseded by generateContent for Gemini, the AQA API only supports the aqa model). This may mean that the full spec behaves poorly, and you'd be better off with hand-edited specs for specific use-cases (like "question answering with AQA" or "multi-modal chat with gemini 1.5").
Either way, I'll leave this open to collect interest. Add a :+1: on the OP if you want this, and describe your case here so we can think about how to support it.
Hi, I would very much like to see and OpenAPI/Swagger Schema for Gemini. I just needed to use it today.
I'm building an application in Rust invokes Gemini and gets output from it. Instead of doing all of these requests by hand through the reqwest library, I typically prefer to have and entire client and models generated for me through the openapi-generator tool.
I understand that you want to have your own SDKs/API Wrappers that are maintained internally, but I think that users in non-supported languages would also like to be able to generate their own clients for your API even if these clients are not as high quality as the clients that you've written internally.
Thanks for the additional context.
While this is in the backlog, I've left some details on another post that might help if you or someone else is looking for a way to get an openapi spec, or a way to generate a client library.
Here's what I posted last year on this thread:
We don't use OpenAPI specs for our APIs, we use protocol buffer specs that are converted to discovery documents for, e.g. auto-generated client libraries.
Here's the service definition in proto format, and here's the discovery URL (make sure you substitute your API key)
I believe we can turn OpenAPI output on but I'd need to look into what trade-offs/compatibility issues there are, if any.
Have you tried using a converter? e.g. gnostic will generate openapi from the proto def, and there are other tools that do discovery → openapi, as well as catalogues of converted API specs.
OK - we have now published an OpenAPI spec on the API:
https://generativelanguage.googleapis.com/$discovery/OPENAPI3_0?version=v1beta&key=$GOOGLE_API_KEY
e.g.
curl "https://generativelanguage.googleapis.com/\$discovery/OPENAPI3_0?version=v1beta&key=$GOOGLE_API_KEY" |jq '.paths |keys'
what is the license of that openapi file? can i check it into my git repo? I don't want to fetch it at build time (and then i would need an google api key at build time)