generateContent and streamGenerateContent in the
Gemini protocol. A client request in OpenAI or Claude format that is routed to
one of these providers is converted to Gemini first, so it works there too,
and the client still receives a response in its own format.
Magic strings
Embed these strings in any text of the prompt:
The strings are part of the protocol between the client and GPROXY and do not
change between versions.
Enabling
Enable it in the providerconfig:
aistudio, vertex, vertexexpress, geminicli, antigravity and playground. The console shows it as
“Enable Gemini magic tool delivery”.
These channels remove the strings from a request whether the switch is on or
off. With the switch off, only the strings are removed and nothing else
changes. A body without a string is forwarded byte for byte; it is neither
parsed nor serialized again.
Tool delivery
When the first string appears in a request, GPROXY removes it and adds one function declaration and a configuration that forces the call:narrative is replaced by a text part that holds
the text argument. The other fields of that part, thoughtSignature
included, are kept, and thought parts are unchanged:
Context wrapping
The text between the second and third strings is moved out ofsystemInstruction and contents into the function’s description. Each
message becomes one section, in request order, with the system instruction
first:
- The text is cut at the exact position of the strings. When a string falls inside a message, the part outside the range stays in that message and the part inside the range moves into the description.
- A start without an end extends the range to the end of the request.
- Non-text parts in the range, such as images, stay where they are. Thought parts in the range are dropped.
- A part or a message left without text is removed.
- When no user message is left outside the range, GPROXY appends one user
message:
Read the narrative tool's description, then call it with your reply.
Limits
- When the client declares
toolsof its own, built-in tools such asgoogleSearchincluded, the feature is not applied and only the strings are removed. - Gemini sends the arguments of a function call as a whole. With the feature on, the text of a streamed response arrives at once after the model has finished writing it, not incrementally.
- The protocol of the
playgroundchannel has no place for the calling mode, so the function is declared but not forced. For a reliable call, state in the prompt that the whole reply must be delivered through thenarrativefunction. - GPROXY adds no instruction to the prompt, apart from the appended user message described above.