Portkey provides a robust and secure gateway to facilitate the integration of various Large Language Models (LLMs) into your applications, including Recraft AI APIs.

With Portkey, you can take advantage of features like fast AI gateway access, observability, prompt management, and more, all while ensuring the secure management of your LLM API keys through a virtual key system.

Provider Slug. recraft-ai

Portkey SDK Integration with Recraft AI Models

Portkey provides a consistent API to interact with models from various providers. Recraft AI currently has the following models available for integration:

  • recraftv3
  • recraftv2

Image Generation on Recraft AI using Portkey

Portkey supports the OpenAI signature to make text-to-image requests.

import Portkey from 'portkey-ai';

// Initialize the Portkey client
const portkey = new Portkey({
    apiKey: "PORTKEY_API_KEY",  // Replace with your Portkey API key
    provider: "recraft-ai",
    Authorization: "RECRAFT_API_KEY"
});

async function main() {
  const image = await portkey.images.generate({
    model: "recraftv3",
    prompt: "Lucy in the sky with diamonds",
    style: 'digital_illustration',
  });

  console.log(image.data);
}

main();

You’ll find more information in the relevant sections:

  1. Add metadata to your requests
  2. Add gateway configs to your Recraft AI requests
  3. Tracing Recraft AI requests
  4. Setup a fallback from OpenAI to Recraft AI APIs

Was this page helpful?