The project is in a healthy, maintained state
The Grok Imagine Ruby SDK is the language-specific package for Grok Imagine on RunAPI. Use this package for image and video generation, image editing, and creative production workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

~> 0.3.0
 Project Readme

RunAPI

Grok Imagine API SDKs for JavaScript, Python, Ruby, Go, Java, and PHP on RunAPI.

npm PyPI RubyGems Go Reference Maven Central License


The Grok Imagine API SDK packages JavaScript, Python, Ruby, Go, Java, and PHP clients for Grok Imagine on RunAPI. Use it for text-to-image, text-to-video, image-to-video, image editing, extension, and upscale workflows when your app needs typed request builders, predictable task polling, file upload helpers, account helpers, and consistent RunAPI errors.

Grok Imagine is listed in the RunAPI model catalog at https://runapi.ai/models/grok-imagine. Variant pages below carry pricing, rate-limit, and commercial-usage details, including the shared grok-imagine-video-1.5-fast and grok-imagine-video-1.5-preview models for text-to-video and image-to-video. The public grok-imagine-sdk repository groups the non-PHP language packages, examples, CI, and release tags for this model. The PHP package is released from a split Composer repository.

Install

npm install @runapi.ai/grok-imagine
pip install runapi-grok-imagine
gem install runapi-grok-imagine
go get github.com/runapi-ai/grok-imagine-sdk/go@latest

Gradle:

dependencies {
  implementation("ai.runapi:runapi-grok-imagine:0.1.5")
}

Maven:

<dependency>
  <groupId>ai.runapi</groupId>
  <artifactId>runapi-grok-imagine</artifactId>
  <version>0.1.5</version>
</dependency>

Use the Java BOM when installing multiple RunAPI Java modules:

dependencies {
  implementation(platform("ai.runapi:runapi-bom:0.2.8"))
  implementation("ai.runapi:runapi-grok-imagine")
}

The PHP package is published from the split Composer repository as runapi-ai/grok-imagine; see https://github.com/runapi-ai/grok-imagine-php for PHP install and examples.

What you can build

  • Build apps, agent workflows, batch jobs, and production services around Grok Imagine requests.
  • Install only the language package your app needs while keeping one model-specific repository for docs and releases.
  • Use create for submit-only jobs, get for status lookup, and run for submit-and-poll scripts.
  • Use grok-imagine-video-1.5-preview on either text-to-video or image-to-video when you need the preview video model.
  • Use grok-imagine-video-1.5-fast on either text-to-video or image-to-video for fast iteration, reference images, and clips up to 30 seconds.
  • Upload local files, URL files, or base64 files through shared RunAPI file helpers.
  • Handle validation, authentication, rate limits, insufficient credits, task failures, and polling timeouts through RunAPI SDK errors.

Java quick start

import ai.runapi.grokimagine.GrokImagineClient;
import ai.runapi.grokimagine.types.TextToImageParams;
import ai.runapi.grokimagine.types.CompletedTextToImageResponse;
import ai.runapi.grokimagine.types.TextToImageModel;

GrokImagineClient client = GrokImagineClient.builder()
    .apiKey(System.getenv("RUNAPI_API_KEY"))
    .build();

CompletedTextToImageResponse result = client.textToImage().run(
    TextToImageParams.builder()
        .model(TextToImageModel.GROK_IMAGINE_TEXT_TO_IMAGE)
        .prompt("A neon city street after rain")
        .aspectRatio("16:9")
        .build()
);

Java packages target Java 8 bytecode and are tested on Java 8, 11, 17, and 21. Each model artifact depends on ai.runapi:runapi-core, so application code normally installs only ai.runapi:runapi-grok-imagine.

Task lifecycle

Most media endpoints are asynchronous. create() submits a task and returns its id, get(id) fetches the latest task state, and run(params) creates the task and polls until it reaches a terminal state. In web request handlers, prefer create() plus webhook or later get() polling so the server does not hold a worker open.

Repository layout

  • js/ publishes @runapi.ai/grok-imagine.
  • python/ publishes runapi-grok-imagine.
  • ruby/ publishes runapi-grok-imagine.
  • go/ publishes github.com/runapi-ai/grok-imagine-sdk/go and depends on github.com/runapi-ai/core-sdk/go.
  • java/ publishes ai.runapi:runapi-grok-imagine and depends on ai.runapi:runapi-core.

Public links

Pricing and variants

Use the most specific Grok Imagine variant page for pricing, rate limits, and commercial usage:

Default pricing link for the Grok Imagine SDK: https://runapi.ai/models/grok-imagine/text-to-video

File storage

RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.

FAQ

Which package should I install for Grok Imagine work?

Install the model package for your language: @runapi.ai/grok-imagine on npm, runapi-grok-imagine on PyPI, runapi-grok-imagine on RubyGems, github.com/runapi-ai/grok-imagine-sdk/go, ai.runapi:runapi-grok-imagine on Maven Central, or runapi-ai/grok-imagine on Packagist. Install core SDK packages only when you are building shared SDK infrastructure.

Where should public links point?

Primary Grok Imagine links point to https://runapi.ai/models/grok-imagine. Pricing and usage-policy links point to variant pages such as https://runapi.ai/models/grok-imagine/text-to-video. Provider comparisons point to https://runapi.ai/providers/xai, and broad browsing points to https://runapi.ai/models.

License

Licensed under the Apache License, Version 2.0.