← Corpus / lost-in-public / prompt

Ask a Model API to Perform a Task via API

Guidelines for making API calls to LLM services like Claude, GPT-4, and Groq

Path
prompts/workflow/Write-an-AI-Model-request-Script.md
Authors
Michael Staton
Augmented with
Windsurf Cascade on Claude 3.5 Sonnet
Tags
AI-Human-Workflow · Model-APIs · LLM-Services · API-Integrations

Inputs

Model API

We will use the Recraft API to generate images.

Example Requests and Responses

ai-labs/recraft/recraft-examples.md

Preferred Style

vector_illustration

API Key

ai-labs/.env

Target Files

site/src/content/lost-in-public/prompts/workflow/code-style

Target Output

Put the response back into the YAML frontmatter of the input file, preserving all other frontmatter structure and formatting.

banner_image: <URL>

Output Script in:

ai-labs/recraft/recraft-generate-banner-images.ts

Including Custom Styles from Recraft

How to Use Your Generated Custom Style

You can include a custom style generated by the Recraft API in your model request by referencing its style ID or by loading the style JSON object. Example below uses the style you generated and saved at:

ai-labs/recraft/styles-recraft-2025-04-14T21-24-01.json

Sample Style JSON:

{
  "creation_time": "2025-04-15T02:24:01.574783871Z",
  "credits": 40,
  "id": "73a249b2-879e-4240-9973-c6fb1715a882",
  "is_private": true,
  "style": "digital_illustration"
}

Example (Python):

import json
with open('ai-labs/recraft/styles-recraft-2025-04-14T21-24-01.json') as f:
    style_obj = json.load(f)
# Use style_obj['id'] as the style identifier in your API request
payload = {
    'prompt': 'Your image prompt here',
    'style': style_obj['id'],
    # ...other parameters
}

Example (JS/TS):

const style = require('./ai-labs/recraft/styles-recraft-2025-04-14T21-24-01.json');
// Use style.id as the style identifier in your API request
const payload = {
  prompt: 'Your image prompt here',
  style: style.id,
  // ...other parameters
};