Skip to content

Align client.images.generate() with OpenAI-compatible response schema #11

@flyworker

Description

@flyworker

Context

The current ImagesResource.generate() uses a custom request/response schema. mega-nova-api is standardizing on OpenAI-compatible format (MeganovaAI/mega-nova-api#434). The SDK should align.

Current State

  • Request params: prompt, model, width, height, num_steps, guidance_scale, seed
  • Response: ImageGenerationResponse(data: List[GeneratedImage]) where GeneratedImage(b64_json, revised_prompt)

Required Changes

  • Add OpenAI-standard parameters: size (e.g. '1024x1024'), n, response_format ('url' or 'b64_json'), quality, style
  • Keep backward-compat with custom params (width/height/num_steps) as aliases
  • Support response_format='url' (return URL instead of base64)
  • Align response model with OpenAI:
    class ImageData(BaseModel):
        url: Optional[str]
        b64_json: Optional[str]
        revised_prompt: Optional[str]
  • Update example: examples/image_generation.py

Backward Compatibility

Keep existing params working — width=1024, height=1024 maps to size='1024x1024' internally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestready for testImplementation complete, ready for QA testing

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions