253 lines
7.7 KiB
YAML
253 lines
7.7 KiB
YAML
openapi: 3.0.1
|
|
info:
|
|
title: Generative Manim API
|
|
description: API for generating Manim code, converting it to video, and handling chat-based code generation.
|
|
version: 1.0.0
|
|
license:
|
|
name: Apache License, Version 2.0
|
|
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
|
|
|
servers:
|
|
- url: http://localhost:8080
|
|
|
|
paths:
|
|
/generate-code:
|
|
post:
|
|
summary: Generate Manim Code
|
|
description: Generates Manim code based on a provided prompt using either OpenAI or Anthropic models.
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
prompt:
|
|
type: string
|
|
description: The prompt to generate Manim code.
|
|
example: Create a blue circle and animate its creation.
|
|
model:
|
|
type: string
|
|
description: The model to use for code generation (e.g., 'gpt-4o' for OpenAI or 'claude-3-haiku-20240307' for Anthropic).
|
|
example: gpt-4o
|
|
responses:
|
|
'200':
|
|
description: Successful response with generated code
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
code:
|
|
type: string
|
|
description: The generated Manim code.
|
|
'500':
|
|
description: Internal Server Error
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
error:
|
|
type: string
|
|
|
|
/chat:
|
|
post:
|
|
summary: Chat for Code Generation
|
|
description: Handles chat requests for both Anthropic and OpenAI models to assist with Manim code generation.
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
messages:
|
|
type: array
|
|
items:
|
|
type: object
|
|
properties:
|
|
role:
|
|
type: string
|
|
content:
|
|
oneOf:
|
|
- type: string
|
|
- type: array
|
|
items:
|
|
type: object
|
|
engine:
|
|
type: string
|
|
enum: [openai, anthropic]
|
|
default: openai
|
|
responses:
|
|
'200':
|
|
description: Successful response with streaming content
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
stream:
|
|
type: boolean
|
|
response:
|
|
type: object
|
|
'500':
|
|
description: Internal Server Error
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
error:
|
|
type: string
|
|
|
|
/v1/video/rendering:
|
|
post:
|
|
summary: Convert Code to Video
|
|
description: Converts provided Manim code to a video and uploads it to storage.
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
code:
|
|
type: string
|
|
description: The Manim code to convert to video.
|
|
file_name:
|
|
type: string
|
|
description: The name of the file to save the code.
|
|
file_class:
|
|
type: string
|
|
description: The class name to render.
|
|
user_id:
|
|
type: string
|
|
description: The user ID for the video.
|
|
default: "anonymous"
|
|
project_name:
|
|
type: string
|
|
description: The project name for the video.
|
|
iteration:
|
|
type: integer
|
|
description: The iteration number for naming the video.
|
|
aspect_ratio:
|
|
type: string
|
|
description: The aspect ratio of the video (16:9, 1:1, or 9:16).
|
|
default: "16:9"
|
|
stream:
|
|
type: boolean
|
|
description: Whether to stream the percentage of animation shown.
|
|
default: false
|
|
responses:
|
|
'200':
|
|
description: Successful response with video URL
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
message:
|
|
type: string
|
|
description: Success message.
|
|
video_url:
|
|
type: string
|
|
description: URL of the generated video.
|
|
'207':
|
|
description: Streaming response with animation progress
|
|
content:
|
|
text/event-stream:
|
|
schema:
|
|
type: string
|
|
description: JSON-encoded progress updates or error messages.
|
|
'400':
|
|
description: Bad Request
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
error:
|
|
type: string
|
|
description: Error message.
|
|
'500':
|
|
description: Internal Server Error
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
error:
|
|
type: string
|
|
description: Error message.
|
|
|
|
/v1/chat/generation:
|
|
post:
|
|
summary: Generate Chat-based Manim Code
|
|
description: Generates Manim code based on a chat conversation using either OpenAI or Anthropic models.
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
messages:
|
|
type: array
|
|
items:
|
|
type: object
|
|
properties:
|
|
role:
|
|
type: string
|
|
content:
|
|
oneOf:
|
|
- type: string
|
|
- type: array
|
|
items:
|
|
type: object
|
|
globalPrompt:
|
|
type: string
|
|
userId:
|
|
type: string
|
|
scenes:
|
|
type: array
|
|
items:
|
|
type: object
|
|
projectTitle:
|
|
type: string
|
|
engine:
|
|
type: string
|
|
enum: [openai, anthropic]
|
|
default: openai
|
|
selectedScenes:
|
|
type: array
|
|
items:
|
|
type: string
|
|
responses:
|
|
'200':
|
|
description: Successful streaming response with generated content
|
|
content:
|
|
text/event-stream:
|
|
schema:
|
|
type: string
|
|
description: Streamed content from the AI model.
|
|
'500':
|
|
description: Internal Server Error
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
error:
|
|
type: string
|
|
|
|
components:
|
|
securitySchemes:
|
|
ApiKeyAuth:
|
|
type: apiKey
|
|
in: header
|
|
name: X-API-Key
|
|
|
|
security:
|
|
- ApiKeyAuth: []
|