ReqLLM.Providers.GoogleVertex.OpenAICompat (ReqLLM v1.13.0)

View Source

OpenAI-compatible model family support for Google Vertex AI.

Handles third-party MaaS (Model-as-a-Service) models on Vertex AI that use the OpenAI Chat Completions API format.

Currently supports:

  • GLM models (zai-org/glm-4.7-maas)
  • OpenAI OSS models (openai/gpt-oss-120b-maas, openai/gpt-oss-20b-maas)
  • Other future MaaS models using OpenAI-compatible format

These models are accessed via Vertex AI's endpoints/openapi/chat/completions endpoint and use standard OpenAI Chat Completions request/response format. The model ID (e.g., zai-org/glm-4.7-maas) is included in the request body.

Summary

Functions

Decodes Server-Sent Events for streaming responses.

Extracts usage metadata from the response body.

Formats a ReqLLM context into OpenAI Chat Completions request format.

Parses OpenAI Chat Completions response from Vertex AI into ReqLLM format.

Functions

decode_stream_event(event, model)

Decodes Server-Sent Events for streaming responses.

Uses the standard OpenAI SSE format decoder from Provider.Defaults.

extract_usage(body, model)

Extracts usage metadata from the response body.

OpenAI-compatible format has standard usage field.

format_request(model_id, context, opts)

Formats a ReqLLM context into OpenAI Chat Completions request format.

Uses the standard OpenAI-compatible body builder from Provider.Defaults.

parse_response(body, model, opts)

Parses OpenAI Chat Completions response from Vertex AI into ReqLLM format.

Returns {:error, %ReqLLM.Error.API.Request{}} for responses containing an "error" key. Otherwise delegates to Provider.Defaults for standard OpenAI response decoding.