Grok Imagine
xAI · Image · Image, per image
grok-imagine
Try
Pricing
| Image | Rp 400 |
|---|
MarkasAI sale prices in Rupiah, read from the same catalog as GET /v1/models. Prices can change and apply to later requests.
Specifications
- Model ID
grok-imagine- Provider
- xAI
- Type
- Image
- Endpoint
POST /v1/images/generations
Call example
curl https://api.markas.ai.id/v1/images/generations \
-H "Authorization: Bearer $MARKASAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "grok-imagine", "prompt": "an orange cat asleep on a sofa", "n": 1}'
import base64, os
from openai import OpenAI
client = OpenAI(base_url="https://api.markas.ai.id/v1", api_key=os.environ["MARKASAI_API_KEY"])
img = client.images.generate(model="grok-imagine", prompt="an orange cat asleep on a sofa", n=1, response_format="b64_json")
with open("image.png", "wb") as f:
f.write(base64.b64decode(img.data[0].b64_json))
import { writeFile } from "node:fs/promises";
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.markas.ai.id/v1", apiKey: process.env.MARKASAI_API_KEY });
const img = await client.images.generate({ model: "grok-imagine", prompt: "an orange cat asleep on a sofa", n: 1, response_format: "b64_json" });
await writeFile("image.png", Buffer.from(img.data[0].b64_json, "base64"));
Keep your API key in the MARKASAI_API_KEY environment variable. Read the endpoint docs