Documentation Index
Fetch the complete documentation index at: https://docs.legnext.ai/llms.txt
Use this file to discover all available pages before exploring further.
GenerateImage()
Create a new text-to-image generation task.
package main
import (
"context"
"fmt"
"os"
legnext "github.com/legnext-ai/sdks/sdks/go"
)
func main() {
config := legnext.NewConfiguration()
config.Servers = legnext.ServerConfigurations{
{
URL: "https://api.legnext.ai",
},
}
apiKey := os.Getenv("LEGNEXT_API_KEY")
config.AddDefaultHeader("x-api-key", apiKey)
client := legnext.NewAPIClient(config)
ctx := context.Background()
// Create image generation request
text := "a serene mountain landscape at sunset"
callback := "https://your-domain.com/webhook"
request := legnext.DiffusionRequest{
Text: &text,
Callback: &callback,
}
response, httpRes, err := client.ImageGenerationAPI.GenerateImage(ctx).
DiffusionRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Job ID: %s\n", *response.JobId)
fmt.Printf("Status: %s\n", *response.Status)
}
Parameters:
Text (string): Text prompt (1-8192 characters)
Callback (string, optional): Webhook URL for completion notification
Returns: Response with JobId and Status
VaryImage()
Create variations of a generated image.
jobId := "original-job-id"
imageNo := int32(0)
varyType := int32(1) // 0=Subtle, 1=Strong
remixPrompt := "add more clouds"
callback := "https://your-domain.com/webhook"
request := legnext.VaryRequest{
JobId: &jobId,
ImageNo: &imageNo,
Type: &varyType,
RemixPrompt: &remixPrompt,
Callback: &callback,
}
response, httpRes, err := client.ImageGenerationAPI.VaryImage(ctx).
VaryRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Variation Job ID: %s\n", *response.JobId)
Parameters:
JobId (string): Original image job ID
ImageNo (int32): Image index (0-3)
Type (int32): Variation type (0=Subtle, 1=Strong)
RemixPrompt (string, optional): Additional prompt for variation
Callback (string, optional): Webhook URL
RemixImage()
Transform an image with a new prompt.
jobId := "original-job-id"
imageNo := int32(0)
remixPrompt := "transform into a dramatic storm scene"
mode := int32(0) // 0=Strong, 1=Subtle
callback := "https://your-domain.com/webhook"
request := legnext.RemixRequest{
JobId: &jobId,
ImageNo: &imageNo,
RemixPrompt: &remixPrompt,
Mode: &mode,
Callback: &callback,
}
response, httpRes, err := client.ImageGenerationAPI.RemixImage(ctx).
RemixRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Remix Job ID: %s\n", *response.JobId)
Parameters:
JobId (string): Original image job ID
ImageNo (int32): Image index (0-3)
RemixPrompt (string): New prompt to apply to the image
Mode (int32): Remix intensity (0=Strong, 1=Subtle)
Callback (string, optional): Webhook URL
UpscaleImage()
Upscale a generated image to higher resolution.
jobId := "original-job-id"
imageNo := int32(0)
upscaleType := int32(1) // 0=Subtle, 1=Creative
callback := "https://your-domain.com/webhook"
request := legnext.UpscaleRequest{
JobId: &jobId,
ImageNo: &imageNo,
Type: &upscaleType,
Callback: &callback,
}
response, httpRes, err := client.ImageGenerationAPI.UpscaleImage(ctx).
UpscaleRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Upscale Job ID: %s\n", *response.JobId)
Parameters:
JobId (string): Original image job ID
ImageNo (int32): Image index (0-3)
Type (int32): Upscale type (0=Subtle, 1=Creative)
Callback (string, optional): Webhook URL
RerollImage()
Regenerate with the same prompt.
jobId := "original-job-id"
callback := "https://your-domain.com/webhook"
request := legnext.RerollRequest{
JobId: &jobId,
Callback: &callback,
}
response, httpRes, err := client.ImageGenerationAPI.RerollImage(ctx).
RerollRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Reroll Job ID: %s\n", *response.JobId)
Parameters:
JobId (string): Original image job ID
Callback (string, optional): Webhook URL
BlendImages()
Blend 2-5 images together.
imageUrls := []string{
"https://example.com/image1.png",
"https://example.com/image2.png",
}
aspectRatio := "1:1" // Options: 1:1, 16:9, 9:16, 3:2, 2:3
callback := "https://your-domain.com/webhook"
request := legnext.BlendRequest{
ImgUrls: imageUrls,
AspectRatio: &aspectRatio,
Callback: &callback,
}
response, httpRes, err := client.ImageGenerationAPI.BlendImages(ctx).
BlendRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Blend Job ID: %s\n", *response.JobId)
Parameters:
ImgUrls ([]string): Array of 2-5 image URLs
AspectRatio (string, optional): Output aspect ratio (1:1, 16:9, 9:16, 3:2, 2:3)
Callback (string, optional): Webhook URL
DescribeImage()
Generate text descriptions from an image.
imgUrl := "https://example.com/image.png"
callback := "https://your-domain.com/webhook"
request := legnext.DescribeRequest{
ImgUrl: &imgUrl,
Callback: &callback,
}
response, httpRes, err := client.ImageGenerationAPI.DescribeImage(ctx).
DescribeRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Describe Job ID: %s\n", *response.JobId)
Parameters:
ImgUrl (string): URL of the image to describe
Callback (string, optional): Webhook URL
EditImage()
Edit an image with text description.
jobId := "original-job-id"
imageNo := int32(0)
canvas := "1:1" // Canvas size
imgPos := int32(0) // Image position
remixPrompt := "change the sky to sunset colors"
callback := "https://your-domain.com/webhook"
request := legnext.EditRequest{
JobId: &jobId,
ImageNo: &imageNo,
Canvas: &canvas,
ImgPos: &imgPos,
RemixPrompt: &remixPrompt,
Callback: &callback,
}
response, httpRes, err := client.ImageGenerationAPI.EditImage(ctx).
EditRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Edit Job ID: %s\n", *response.JobId)
Parameters:
JobId (string): Original image job ID
ImageNo (int32): Image index (0-3)
Canvas (string): Canvas size (e.g., “1:1”)
ImgPos (int32): Image position
RemixPrompt (string): Edit instructions
Callback (string, optional): Webhook URL
InpaintImage()
Fill masked regions in an image.
jobId := "original-job-id"
imageNo := int32(0)
remixPrompt := "fill with forest landscape"
mask := "mask-url-or-coordinates"
callback := "https://your-domain.com/webhook"
request := legnext.InpaintRequest{
JobId: &jobId,
ImageNo: &imageNo,
RemixPrompt: &remixPrompt,
Mask: &mask,
Callback: &callback,
}
response, httpRes, err := client.ImageGenerationAPI.InpaintImage(ctx).
InpaintRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Inpaint Job ID: %s\n", *response.JobId)
Parameters:
JobId (string): Original image job ID
ImageNo (int32): Image index (0-3)
RemixPrompt (string): Inpainting prompt
Mask (string): Mask data or coordinates
Callback (string, optional): Webhook URL
OutpaintImage()
Extend image boundaries.
jobId := "original-job-id"
imageNo := int32(0)
scale := float32(1.5) // Scale factor (1.1-3.0)
remixPrompt := "extend with matching scenery"
callback := "https://your-domain.com/webhook"
request := legnext.OutpaintRequest{
JobId: &jobId,
ImageNo: &imageNo,
Scale: &scale,
RemixPrompt: &remixPrompt,
Callback: &callback,
}
response, httpRes, err := client.ImageGenerationAPI.OutpaintImage(ctx).
OutpaintRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Outpaint Job ID: %s\n", *response.JobId)
Parameters:
JobId (string): Original image job ID
ImageNo (int32): Image index (0-3)
Scale (float32): Scale factor (1.1-3.0)
RemixPrompt (string, optional): Outpainting prompt
Callback (string, optional): Webhook URL
PanImage()
Create panoramic or panned views.
jobId := "original-job-id"
imageNo := int32(0)
direction := int32(1) // 0=Down, 1=Right, 2=Up, 3=Left
scale := float32(1.5) // Scale factor (1.1-3.0)
remixPrompt := "pan to the right with continuous scenery"
callback := "https://your-domain.com/webhook"
request := legnext.PanRequest{
JobId: &jobId,
ImageNo: &imageNo,
Direction: &direction,
Scale: &scale,
RemixPrompt: &remixPrompt,
Callback: &callback,
}
response, httpRes, err := client.ImageGenerationAPI.PanImage(ctx).
PanRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Pan Job ID: %s\n", *response.JobId)
Parameters:
JobId (string): Original image job ID
ImageNo (int32): Image index (0-3)
Direction (int32): Pan direction (0=Down, 1=Right, 2=Up, 3=Left)
Scale (float32): Scale factor (1.1-3.0)
RemixPrompt (string, optional): Panning prompt
Callback (string, optional): Webhook URL
ShortenPrompt()
Optimize and simplify prompts.
prompt := "your very long and detailed prompt here with lots of unnecessary words and descriptions that could be made more concise..."
request := legnext.ShortenRequest{
Prompt: &prompt,
}
response, httpRes, err := client.ImageGenerationAPI.ShortenPrompt(ctx).
ShortenRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Shortened prompt: %s\n", *response.ShortenedPrompt)
Parameters:
Prompt (string): Long prompt to optimize
Returns: Response with ShortenedPrompt
Complete Example
package main
import (
"context"
"fmt"
"os"
legnext "github.com/legnext-ai/sdks/sdks/go"
)
func main() {
// Configure API client
config := legnext.NewConfiguration()
config.Servers = legnext.ServerConfigurations{
{
URL: "https://api.legnext.ai",
},
}
apiKey := os.Getenv("LEGNEXT_API_KEY")
config.AddDefaultHeader("x-api-key", apiKey)
client := legnext.NewAPIClient(config)
ctx := context.Background()
// Step 1: Generate image
text := "a beautiful sunset over mountains"
callback := "https://your-domain.com/webhook"
request := legnext.DiffusionRequest{
Text: &text,
Callback: &callback,
}
response, _, err := client.ImageGenerationAPI.GenerateImage(ctx).
DiffusionRequest(request).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
jobId := *response.JobId
fmt.Printf("Image generation started: %s\n", jobId)
// Step 2: Wait for completion (see Task Management docs)
// ...
// Step 3: Upscale the first image
imageNo := int32(0)
upscaleType := int32(1)
upscaleRequest := legnext.UpscaleRequest{
JobId: &jobId,
ImageNo: &imageNo,
Type: &upscaleType,
}
upscaleResponse, _, err := client.ImageGenerationAPI.UpscaleImage(ctx).
UpscaleRequest(upscaleRequest).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Upscale started: %s\n", *upscaleResponse.JobId)
}
Next Steps