Documentation
¶
Overview ¶
Package geminiCLI provides request translation functionality for Gemini CLI to Claude Code API compatibility. It handles parsing and transforming Gemini CLI API requests into Claude Code API format, extracting model information, system instructions, message contents, and tool declarations. The package performs JSON data transformation to ensure compatibility between Gemini CLI API format and Claude Code API's expected format.
Package geminiCLI provides response translation functionality for Claude Code to Gemini CLI API compatibility. This package handles the conversion of Claude Code API responses into Gemini CLI-compatible JSON format, transforming streaming events and non-streaming responses into the format expected by Gemini CLI API clients.
Index ¶
- func ConvertClaudeResponseToGeminiCLI(ctx context.Context, modelName string, ...) []string
- func ConvertClaudeResponseToGeminiCLINonStream(ctx context.Context, modelName string, ...) string
- func ConvertGeminiCLIRequestToClaude(modelName string, inputRawJSON []byte, stream bool) []byte
- func GeminiCLITokenCount(ctx context.Context, count int64) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertClaudeResponseToGeminiCLI ¶
func ConvertClaudeResponseToGeminiCLI(ctx context.Context, modelName string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, param *any) []string
ConvertClaudeResponseToGeminiCLI converts Claude Code streaming response format to Gemini CLI format. This function processes various Claude Code event types and transforms them into Gemini-compatible JSON responses. It handles text content, tool calls, and usage metadata, outputting responses that match the Gemini CLI API format. The function wraps each converted response in a "response" object to match the Gemini CLI API structure.
Parameters:
- ctx: The context for the request, used for cancellation and timeout handling
- modelName: The name of the model being used for the response
- rawJSON: The raw JSON response from the Claude Code API
- param: A pointer to a parameter object for maintaining state between calls
Returns:
- []string: A slice of strings, each containing a Gemini-compatible JSON response wrapped in a response object
func ConvertClaudeResponseToGeminiCLINonStream ¶
func ConvertClaudeResponseToGeminiCLINonStream(ctx context.Context, modelName string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, param *any) string
ConvertClaudeResponseToGeminiCLINonStream converts a non-streaming Claude Code response to a non-streaming Gemini CLI response. This function processes the complete Claude Code response and transforms it into a single Gemini-compatible JSON response. It wraps the converted response in a "response" object to match the Gemini CLI API structure.
Parameters:
- ctx: The context for the request, used for cancellation and timeout handling
- modelName: The name of the model being used for the response
- rawJSON: The raw JSON response from the Claude Code API
- param: A pointer to a parameter object for the conversion
Returns:
- string: A Gemini-compatible JSON response wrapped in a response object
func ConvertGeminiCLIRequestToClaude ¶
ConvertGeminiCLIRequestToClaude parses and transforms a Gemini CLI API request into Claude Code API format. It extracts the model name, system instruction, message contents, and tool declarations from the raw JSON request and returns them in the format expected by the Claude Code API. The function performs the following transformations: 1. Extracts the model information from the request 2. Restructures the JSON to match Claude Code API format 3. Converts system instructions to the expected format 4. Delegates to the Gemini-to-Claude conversion function for further processing
Parameters:
- modelName: The name of the model to use for the request
- rawJSON: The raw JSON request data from the Gemini CLI API
- stream: A boolean indicating if the request is for a streaming response
Returns:
- []byte: The transformed request data in Claude Code API format
Types ¶
This section is empty.