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

# Spec Operation Examples

> Generate examples for a specific operation of the specified spec.

Generates examples for a specific operation of the specified spec identified by its API name.
Optionally specify the operation name, count, and index.

Parameters:
- api_name (str): The name of the spec to generate examples for.
  examples for.
- payload (SpecExamplePayload): Payload containing operation name, count, and index flags.
- current_user (AuthUser): The current user making the request. Retrieved using dependency injection.

Returns:
- dict: Examples or error detail.

Raises:
- HTTPException(500): If an error occurs while generating the examples.



## OpenAPI

````yaml post /api/spec/{api_name}/operation_examples
openapi: 3.1.0
info:
  title: Apigene
  description: Apigene API
  version: 1.0.0
  contact:
    name: Apigene Support
    url: https://app.apigene.ai
    email: support@apigene.ai
servers:
  - url: https://app.apigene.ai
security:
  - BearerAuth: []
paths:
  /api/spec/{api_name}/operation_examples:
    post:
      tags:
        - Spec
      summary: Spec Operation Examples
      description: >-
        Generate examples for a specific operation of the specified spec.


        Generates examples for a specific operation of the specified spec
        identified by its API name.

        Optionally specify the operation name, count, and index.


        Parameters:

        - api_name (str): The name of the spec to generate examples for.
          examples for.
        - payload (SpecExamplePayload): Payload containing operation name,
        count, and index flags.

        - current_user (AuthUser): The current user making the request.
        Retrieved using dependency injection.


        Returns:

        - dict: Examples or error detail.


        Raises:

        - HTTPException(500): If an error occurs while generating the examples.
      operationId: spec_operation_examples
      parameters:
        - name: api_name
          in: path
          required: true
          schema:
            type: string
            title: Api Name
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpecExamplePayload'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    SpecExamplePayload:
      properties:
        operations_name:
          items:
            type: string
          type: array
          title: Operations Name
          description: The name of the operation for which examples are to be generated.
        context:
          additionalProperties: true
          type: object
          title: Context
          description: >-
            Additional context parameters that may include relevant info for the
            LLM
        count:
          type: integer
          title: Count
          description: The number of examples to generate.
          default: 5
        index:
          type: boolean
          title: Index
          description: Flag indicating whether to use the generated examples to index.
          default: false
        force:
          type: boolean
          title: Force
          description: Flag indicating whether to force re-generation of examples.
          default: false
      type: object
      title: SpecExamplePayload
      description: >-
        Payload model for generating examples for a specific operation of the
        specified spec.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Authorization header using the Bearer scheme. Example:
        'Authorization: Bearer {token}'

````