How to Call the Orauria MCP from a Shopify App (and Generate a Product Image on Order)

Wire a Shopify app to http://orauria.com/api/mcp, call generate_image with a reference, and poll get_task until the product photo is ready.

admin

Author

9 minutes read
Build with Orauria cover: a capybara in a denim vest on a red background, with the headline Generate a product image on order and Call Orauria MCP from a Shopify app

When a shopper uploads a photo — or places an order that needs a unique product picture — you should not have to open Orauria Studio by hand and click Generate. You can call the same models from your Shopify app through the Orauria MCP server, then show the finished image as the preview.

This guide walks through that server-side loop: store an API key in an environment variable, confirm the model and your remaining credits, call generate_image with a prompt and an optional reference image, and poll get_task until the job is finished. The running example is a small custom app for a fictional shop named Fern & Fox Goods. The shop and the people in the illustrations are fictional. The endpoint, the tools, and the billing rule are real.

If you still need a written brief, use Image to prompt in the AI Assistant Copilot – Orauria Chrome extension first. This post focuses on the MCP call that runs after the brief exists.

What you need

Item Where it comes from Notes
A Shopify store you control A development store, not a live checkout while you test A custom app or a server-side Remix route
An Orauria API key Profile → API keys after you sign in The full key is shown only once
A server environment variable process.env.ORAURIA_TOKEN Never put the key in a theme file or a client bundle
The Orauria MCP endpoint http://orauria.com/api/mcp Send a Bearer token in the Authorization header
A prompt, and optionally a reference image URL Your rewrite step, plus the shopper upload Pass the reference in params.images
An image model name list_models with kind image This guide uses tt-image-2.5 (TT Image 2.5)
Credits in the wallet get_wallet MCP bills the same Studio price. A TT Image 2.5 still image is about 0.02 credits

Phase 1. Create a key and keep it on the server

Sign in to Orauria, open Profile → API keys, and create a key. New keys start with sk-. Copy it once and store it as ORAURIA_TOKEN in the environment of your Shopify app: a secret store, a .env file that is not committed, or your host’s environment panel.

In any snippet you publish, write YOUR_ORAURIA_TOKEN or process.env.ORAURIA_TOKEN. Do not paste a real key into a theme, a repository, or a tutorial.

The MCP server authenticates with Authorization: Bearer plus that token. Official examples on the Orauria MCP page use the same URL: http://orauria.com/api/mcp.

Phase 2. Confirm the model and the wallet before you generate

Two tools on the same endpoint spend no image credit and will save you from a failed generate call:

  • list_models with kind image returns the image models available to the key, including tt-image-2.5 (display name TT Image 2.5). That model supports multi-image reference fusion and is a solid default for product photographs.
  • get_wallet returns the remaining credits for the key owner. Official MCP documentation is clear: if credit is too low, the generate call returns an error, and MCP is only a connector — jobs bill the same wallet and prices as Studio.

Call both when you first wire the client, and call get_wallet again before a batch of jobs if you want the app to fail gracefully.

Phase 3. Hook the Shopify upload or order to a server route

The Shopify piece is a custom app you build, not an app Orauria ships. A short Remix or Node route is enough:

  1. The shopper uploads a photo and, if you need it, a short label for the order.
  2. Your action runs only on the server and builds a product-photo prompt.
  3. You call Orauria and return a task id.
  4. A second request polls until the image is ready and shows result_url as the preview.

Work in a development store until the preview looks right, and keep the token and the MCP call out of theme JavaScript.

If you later call Image to prompt from the server, look up the current HTTP path in Orauria’s docs — this post does not invent one.

Illustration of a woman on a sofa in a sunlit apartment, with the headline what happens after checkout and three sticker-style cards labeled Order in, generate_image, and get_task is_final.
Illustration. A stylized look at the loop, not a screenshot of a live store or of the Shopify admin.

Phase 4. Call generate_image with a prompt and a reference

POST to http://orauria.com/api/mcp with JSON that names the tool and its parameters. A compact version of the route looks like this:

// app/routes/api.product-image.ts
const TOKEN = process.env.ORAURIA_TOKEN;
const MCP_URL = "http://orauria.com/api/mcp";

export async function action({ request }) {
  const form = await request.formData();
  const referenceUrl = String(form.get("reference_url") || "");
  const prompt = String(form.get("prompt") || "");

  const started = await fetch(MCP_URL, {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_ORAURIA_TOKEN",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      tool: "generate_image",
      params: {
        model: "tt-image-2.5",
        prompt,
        params: {
          aspect_ratio: "16:9",
          images: [referenceUrl],
        },
      },
    }),
  });

  const startedJson = await started.json();
  return json({ taskId: startedJson.taskId });
}

In production code, send Bearer ${TOKEN}, not the placeholder.

generate_image returns a taskId. It does not wait for the file — the job starts, then you ask for the result, the same way Studio works. TT Image 2.5 is billed per image. A single still has been about 0.02 credits (0.0208 on recent jobs). If you switch models, check the Studio composer or the difference in get_wallet rather than reusing that figure.

Illustration of a code card showing a generate_image request to http://orauria.com/api/mcp with a YOUR_ORAURIA_TOKEN placeholder, model tt-image-2.5, and a get_task poll until is_final is true.
Illustration. Tokens are placeholders. This is a designed code card, not a capture of a production app.

Phase 5. Poll get_task until is_final, then use result_url

Send the taskId to get_task on the same MCP endpoint, with the same Bearer token. Keep polling until the payload reports is_final: true. When the job has succeeded, the payload includes result_url. Download that file, store it with the order, and show it to the shopper as the product photograph.

A compact poll step looks like this:

export async function loader({ request }) {
  const taskId = Number(new URL(request.url).searchParams.get("taskId"));
  const TOKEN = process.env.ORAURIA_TOKEN;

  const res = await fetch("http://orauria.com/api/mcp", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${TOKEN}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      tool: "get_task",
      params: { taskId },
    }),
  });

  const payload = await res.json();
  if (payload.is_final && payload.result_url) {
    return json({ status: "ready", url: payload.result_url });
  }
  return json({ status: "running" });
}

Practical notes for the poll loop:

  • Do not start a second generate_image for the same line item while you are still waiting, unless you intend to spend another credit.
  • Handle a failed or refunded job in the admin, not by retrying forever on the product page.
  • Keep the poll on the server. The browser should only see a generating state and then the preview.
  • Official docs describe get_task as the way to poll until a job finishes. They do not publish a required interval, so pick a short gap and stop when is_final is true.
Illustration of a capybara in a denim vest on a red background, with the stacked headline Call generate_image, then poll get_task.
Illustration. The two-tool sequence after the shopper upload is in your app.

Phase 6. Show the preview, then fulfill

When result_url is in hand, the shopper should see the generated photograph — not a design pasted onto a blank template after the fact. If the object has drifted from the reference, do not send the file to print; rewrite the brief and generate again. How to keep product identity stable covers that check.

A simple review queue helps for the first orders: photo received, prompt ready, image generating, preview sent, sent to print, fulfilled. The MCP call can be automatic; the decision to ship should stay human until you trust the rewrite.

Illustration with the headline Show the generated photo, then fulfill, and a short checklist for preview, identity check, and handoff to print.
Illustration. A reminder of the handoff, not a live fulfillment dashboard.

Practical notes

  • MCP usage costs credits. The connector is not a separate product price; generate_image, generate_video, and chat use the Studio wallet.
  • Pass reference images as URLs your server can reach. Do not embed a customer photo in client-side code.
  • If you started from a public style reference, credit the source and ship a new image, not a reprint. Disclose that the artwork is AI-generated when you sell it.
  • Work in a development store first, and keep secrets out of the theme.

FAQ

Does calling MCP from Shopify cost more than Studio?

No. Official documentation states that MCP is only a connector and that image jobs bill the same wallet and prices as Studio.

Which token should I put in a repository?

Use process.env.ORAURIA_TOKEN in code and the placeholder YOUR_ORAURIA_TOKEN in public examples. Never a real key.

What does generate_image return?

A task id. Poll get_task until is_final is true, then use result_url.

How do I attach a reference image?

Put an image URL in params.images on the generate_image call, and write a prompt that says what must stay the same. TT Image 2.5 supports reference-image fusion. The public MCP page lists the tool but does not spell out every parameter name; this is the params shape used in this series.

Can I list models and check credits from the same app?

Yes. Both tools use the same endpoint and the same Bearer token.

Do I have to use TT Image 2.5?

No. Call list_models and pick an image model that supports your reference workflow. This guide uses TT Image 2.5 because it is listed for product images with reference support, and because a single still has been about 0.02 credits.

Start here

Create an API key, store it in process.env.ORAURIA_TOKEN, and call get_wallet plus list_models from a development store. Then wire one server route that calls generate_image at http://orauria.com/api/mcp and a second step that polls get_task until result_url is ready.

If you still need a brief, install AI Assistant Copilot – Orauria and follow Image to Prompt in 5 Minutes. When the product must stay recognizable, read How to Keep Product Identity Stable.

The Orauria MCP page has client configs if you want to try the same tools from a local chat client first. For help wiring the app, start at Orauria AI outsourcing.

Related articles

Same category Build with Orauria