> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shaktistudio.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemma 3 4B

> Create a chat completion for given messages with streaming support using Google's Gemma-IT model, optimized for instruction following and conversational AI tasks



## OpenAPI

````yaml /openapi-specs/playground/gemma3-4b.yaml POST /chat/completions
openapi: 3.1.0
info:
  title: Gemma3 4B
  description: >-
    Google's Gemma-IT Language Model API for conversational AI, text generation,
    and instruction-following tasks with built-in retry mechanisms
  version: 1.0.0
servers:
  - url: https://http.llm.model-cluster.on-prem.clusters.yotta-uat.cluster.s9t.link
    description: Production LLM Proxy Server
security:
  - BearerAuth: []
tags:
  - name: Chat Completion
    description: Gemma-IT language model chat completion services
paths:
  /chat/completions:
    post:
      tags:
        - Chat Completion
      summary: Create chat completion with Gemma-IT
      description: >-
        Create a chat completion for given messages with streaming support using
        Google's Gemma-IT model, optimized for instruction following and
        conversational AI tasks
      operationId: createChatCompletionGemmaIT
      parameters:
        - in: header
          name: id
          schema:
            type: string
            default: 54e4c0bb-11fc-40f6-94d0-5a6eca081345
          required: true
          description: Model UUID for the request (Gemma-IT model identifier)
          example: 54e4c0bb-11fc-40f6-94d0-5a6eca081345
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                messages:
                  type: array
                  description: Array of messages in the conversation
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - system
                          - user
                          - assistant
                        description: The role of the message sender
                      content:
                        type: string
                        description: The content of the message
                    required:
                      - role
                      - content
                model:
                  type: string
                  description: Model identifier for Gemma-IT
                  enum:
                    - gemma-it
                  default: gemma-it
                stream:
                  type: boolean
                  description: Whether to stream the response
                  default: false
                temperature:
                  type: number
                  description: >-
                    Sampling temperature (0.0 to 2.0). Controls randomness in
                    generation
                  minimum: 0
                  maximum: 2
                  default: 0.7
                max_tokens:
                  type: integer
                  description: Maximum number of tokens to generate
                  minimum: 1
                  maximum: 4096
                  default: 1024
                top_p:
                  type: number
                  description: >-
                    Nucleus sampling parameter for controlling response
                    diversity
                  minimum: 0
                  maximum: 1
                  default: 0.9
                top_k:
                  type: integer
                  description: Top-k sampling parameter for vocabulary selection
                  minimum: 1
                  maximum: 100
                  default: 40
                stop:
                  type: array
                  description: Sequences where the API will stop generating further tokens
                  items:
                    type: string
                  maxItems: 4
                  nullable: true
                frequency_penalty:
                  type: number
                  description: Penalty for frequent tokens to reduce repetition
                  minimum: -2
                  maximum: 2
                  default: 0
                presence_penalty:
                  type: number
                  description: Penalty for new tokens to encourage topic diversity
                  minimum: -2
                  maximum: 2
                  default: 0
                repetition_penalty:
                  type: number
                  description: Penalty for repeating tokens (Gemma-specific parameter)
                  minimum: 0.1
                  maximum: 2
                  default: 1
                do_sample:
                  type: boolean
                  description: Whether to use sampling for generation
                  default: true
                seed:
                  type: integer
                  description: Random seed for reproducible outputs
                  nullable: true
                system_prompt:
                  type: string
                  description: >-
                    System prompt to set model behavior (alternative to system
                    message)
                  nullable: true
              required:
                - messages
                - model
            examples:
              simple_math_query:
                summary: Simple arithmetic question
                value:
                  model: gemma-it
                  messages:
                    - role: user
                      content: what is 2+2?
                  stream: false
                  max_tokens: 1024
              instruction_following:
                summary: Instruction following task
                value:
                  model: gemma-it
                  messages:
                    - role: system
                      content: >-
                        You are a helpful assistant that follows instructions
                        precisely.
                    - role: user
                      content: >-
                        Write a brief summary of the benefits of renewable
                        energy in exactly 3 bullet points.
                  stream: false
                  temperature: 0.3
                  max_tokens: 512
                  top_p: 0.95
              conversational_chat:
                summary: Conversational interaction
                value:
                  model: gemma-it
                  messages:
                    - role: user
                      content: >-
                        Can you explain how machine learning works in simple
                        terms?
                  stream: false
                  temperature: 0.8
                  max_tokens: 2048
                  top_p: 0.9
                  top_k: 50
              creative_writing:
                summary: Creative content generation
                value:
                  model: gemma-it
                  messages:
                    - role: user
                      content: Write a short poem about technology and human connection
                  stream: false
                  temperature: 1
                  max_tokens: 800
                  top_k: 60
              multi_turn_conversation:
                summary: Multi-turn conversation with context
                value:
                  model: gemma-it
                  messages:
                    - role: user
                      content: What's the capital of Japan?
                    - role: assistant
                      content: The capital of Japan is Tokyo.
                    - role: user
                      content: What's the population of that city?
                  stream: true
                  temperature: 0.5
                  max_tokens: 512
      responses:
        '200':
          description: Successful chat completion
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ChatCompletionResponse'
                  - $ref: '#/components/schemas/ChatCompletionChunk'
            text/event-stream:
              schema:
                type: string
                description: Server-sent events for streaming responses
              example: >
                data:
                {"id":"chatcmpl-gemma-it-abc123","object":"chat.completion.chunk","created":1699014493,"model":"gemma-it","choices":[{"index":0,"delta":{"content":"2"},"finish_reason":null}]}


                data:
                {"id":"chatcmpl-gemma-it-abc123","object":"chat.completion.chunk","created":1699014493,"model":"gemma-it","choices":[{"index":0,"delta":{"content":"
                + 2"},"finish_reason":null}]}


                data:
                {"id":"chatcmpl-gemma-it-abc123","object":"chat.completion.chunk","created":1699014493,"model":"gemma-it","choices":[{"index":0,"delta":{"content":"
                = 4"},"finish_reason":"stop"}]}
        '400':
          description: Bad Request - Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                invalid_model:
                  summary: Invalid model specified
                  value:
                    error:
                      message: Invalid model specified. Expected 'gemma-it'
                      type: invalid_request_error
                      code: invalid_model
                token_limit_exceeded:
                  summary: Token limit exceeded
                  value:
                    error:
                      message: max_tokens cannot exceed 4096
                      type: invalid_request_error
                      code: invalid_parameter
                      param: max_tokens
                empty_messages:
                  summary: Empty messages array
                  value:
                    error:
                      message: messages array cannot be empty
                      type: invalid_request_error
                      code: invalid_parameter
                      param: messages
        '401':
          description: Unauthorized - Invalid or missing authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Too Many Requests - Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '502':
          description: Bad Gateway - Gemma model service unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: Service Unavailable - Model temporarily overloaded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ChatCompletionResponse:
      type: object
      description: Response for non-streaming chat completion
      properties:
        id:
          type: string
          description: Unique identifier for the completion
          example: chatcmpl-gemma-it-abc123
        object:
          type: string
          enum:
            - chat.completion
          description: Object type
          example: chat.completion
        created:
          type: integer
          description: Unix timestamp of when the completion was created
          example: 1699014493
        model:
          type: string
          description: The model used for completion
          example: gemma-it
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
                description: Index of the choice
                example: 0
              message:
                type: object
                properties:
                  role:
                    type: string
                    enum:
                      - assistant
                    description: Role of the message sender
                    example: assistant
                  content:
                    type: string
                    description: Generated text content
                    example: >-
                      2 + 2 equals 4. This is a basic arithmetic operation where
                      we add two numbers together to get their sum.
                required:
                  - role
                  - content
              finish_reason:
                type: string
                enum:
                  - stop
                  - length
                  - content_filter
                  - tool_calls
                description: Reason for finishing the generation
                example: stop
            required:
              - index
              - message
              - finish_reason
        usage:
          type: object
          properties:
            prompt_tokens:
              type: integer
              description: Number of tokens in the prompt
              example: 8
            completion_tokens:
              type: integer
              description: Number of tokens in the completion
              example: 24
            total_tokens:
              type: integer
              description: Total number of tokens used
              example: 32
          required:
            - prompt_tokens
            - completion_tokens
            - total_tokens
        system_fingerprint:
          type: string
          description: System fingerprint for the model version
          example: gemma-2-instruct-v1.0
          nullable: true
    ChatCompletionChunk:
      type: object
      description: Response chunk for streaming chat completion
      properties:
        id:
          type: string
          description: Unique identifier for the completion
          example: chatcmpl-gemma-it-abc123
        object:
          type: string
          enum:
            - chat.completion.chunk
          description: Object type
          example: chat.completion.chunk
        created:
          type: integer
          description: Unix timestamp of when the completion was created
          example: 1699014493
        model:
          type: string
          description: The model used for completion
          example: gemma-it
        choices:
          type: array
          items:
            type: object
            properties:
              index:
                type: integer
                description: Index of the choice
                example: 0
              delta:
                type: object
                properties:
                  role:
                    type: string
                    enum:
                      - assistant
                    description: Role of the message sender (only in first chunk)
                    example: assistant
                  content:
                    type: string
                    description: Generated text content chunk
                    nullable: true
                    example: ' + 2'
              finish_reason:
                type: string
                enum:
                  - stop
                  - length
                  - content_filter
                  - tool_calls
                description: Reason for finishing the generation (only in last chunk)
                nullable: true
                example: null
            required:
              - index
              - delta
        system_fingerprint:
          type: string
          description: System fingerprint for the model version
          example: gemma-2-instruct-v1.0
          nullable: true
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error message
              example: Invalid model specified
            type:
              type: string
              description: Error type classification
              example: invalid_request_error
              enum:
                - invalid_request_error
                - authentication_error
                - rate_limit_error
                - server_error
                - model_error
            code:
              type: string
              description: Specific error code
              example: invalid_model
            param:
              type: string
              description: Parameter that caused the error (if applicable)
              example: model
              nullable: true
          required:
            - message
            - type
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT token for authentication - Use your API token as the Bearer token

````