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.
Portkey provides a consistent API to interact with models from various providers. Recraft AI currently has
the following models available for integration:
Portkey supports the OpenAI signature to make text-to-image requests.
import Portkey from 'portkey-ai';// Initialize the Portkey clientconst 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();
import Portkey from 'portkey-ai';// Initialize the Portkey clientconst 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();
from portkey_ai import Portkeyfrom IPython.display import display, Image# Initialize the Portkey clientportkey = Portkey( api_key="PORTKEY_API_KEY", # Replace with your Portkey API key provider= "recraft-ai", Authorization= "RECRAFT_API_KEY")response = client.images.generate( model="recraftv3", prompt='race car on a track', style='digital_illustration',)print(response.data[0].url)
import OpenAI from 'openai'; // We're using the v4 SDKimport { PORTKEY_GATEWAY_URL, createHeaders } from 'portkey-ai'const client = new OpenAI({ apiKey: 'RECRAFT_API_KEY', // defaults to process.env["OPENAI_API_KEY"], baseURL: PORTKEY_GATEWAY_URL, defaultHeaders: createHeaders({ provider: "recraft-ai", apiKey: "PORTKEY_API_KEY" // defaults to process.env["PORTKEY_API_KEY"] })});async function main() { const image = await openai.images.generate({ model: "recraftv3", prompt: 'race car on a track', style: 'digital_illustration', }); console.log(image.data);}main();
from openai import OpenAIfrom portkey_ai import PORTKEY_GATEWAY_URL, createHeadersfrom IPython.display import display, Imageclient = OpenAI( api_key='RECRAFT_API_KEY', base_url=PORTKEY_GATEWAY_URL, default_headers=createHeaders( provider="recraft-ai", api_key="PORTKEY_API_KEY" ))response = client.images.generate( model="recraftv3", prompt='race car on a track', style='digital_illustration',)print(response.data[0].url))# Display the imagedisplay(Image(url=image.data[0].url))