llm-routing/apiproxy/resources/oas/spec.yaml (264 lines of code) (raw):

# Copyright 2024 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. openapi: 3.0.1 info: title: LLM Routing description: Spec for the LLM Routing Sample API termsOfService: https://example.com/ contact: email: someteam@example.com license: name: Apache 2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html version: 1.0.0 externalDocs: description: Find out more about this sample url: https://github.com/GoogleCloudPlatform/apigee-samples/tree/main?tab=readme-ov-file#llm-samples servers: - url: https://HOST/v1/samples/llm-routing tags: - name: chat description: Chat paths: /chat/completions: post: tags: - chat summary: Generate Content using a prompt description: | Creates a model response for the given chat conversation operationId: chat parameters: - name: x-llm-provider in: header description: LLM Provider required: true schema: type: string enum: [google, mistral, huggingface] example: "google" - name: x-logpayload in: header description: Log payload to Cloud Logging example: true required: false schema: type: boolean requestBody: description: | Submit a prompt to generate text content: application/json: schema: $ref: '#/components/schemas/ChatRequest' examples: google: value: { "model": "google/gemini-2.0-flash", "messages": [ { "role": "user", "content": [ { "type": "image_url", "image_url": { "url": "gs://generativeai-downloads/images/character.jpg" } }, { "type": "text", "text": "Describe this image in one sentence." } ] } ], "max_tokens": 250, "stream": false, "top_p": 0.5, "safe_prompt": false, "temperature": 0.7, "n": 1 } mistral: value: { "model": "open-mistral-nemo", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Suggest few names for a flower shop" } ] } ], "max_tokens": 250, "stream": false, "top_p": 0.5, "safe_prompt": false, "temperature": 0.7, "n": 1 } huggingface: value: { "model": "Meta-Llama-3.1-8B-Instruct", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Suggest few names for a flower shop" } ] } ], "max_tokens": 250, "stream": false, "top_p": 0.5, "safe_prompt": false, "temperature": 0.7, "n": 1 } responses: '200': description: successful operation content: application/json: schema: $ref: '#/components/schemas/ChatResponse' '400': description: Invalid request supplied content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '401': description: Uanuthorized content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '403': description: Forbidden content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '404': description: Not Found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' security: - api_key: [] components: schemas: ChatRequest: type: object properties: model: type: string example: "google/gemini-2.0-flash" messages: type: array items: $ref: '#/components/schemas/MessageObj' max_tokens: type: integer example: 250 stream: type: boolean example: false top_p: type: number format: float safe_prompt: type: boolean temperature: type: number format: float n: type: number required: - model - messages MessageObj: type: object properties: role: type: string example: "user" content: type: array items: $ref: '#/components/schemas/ContentObj' ContentObj: type: object properties: type: type: string example: "text" text: type: string example: "Suggest me something" image_url: type: object properties: url: type: string ErrorResponse: type: object ChatResponse: type: object properties: id: type: string model: type: string object: type: string system_fingerprint: type: string created: type: integer format: int32 choices: type: array items: $ref: '#/components/schemas/ChoiceObj' usage: $ref: '#/components/schemas/UsageObj' ChoiceObj: type: object properties: finish_reason: type: string index: type: integer logprobs: type: integer message: type: object properties: content: type: string role: type: string UsageObj: type: object properties: completion_tokens: type: integer prompt_tokens: type: integer total_tokens: type: integer securitySchemes: api_key: type: apiKey name: x-apikey in: header