DEV Community

diwushennian4955
diwushennian4955

Posted on • Originally published at nexa-api.com

CrewAI + NexaAPI: Build Observable AI Agents with $0.003 Image Generation (2026)

CrewAI + NexaAPI: Build Observable AI Agents with $0.003 Image Generation (2026)

LoongSuite just released loongsuite-instrumentation-crewai — an OpenTelemetry-style tracing package for CrewAI agents. Enterprise observability for your AI pipelines is here.

But your agents are only as good as the APIs they call. If you're building observable CrewAI pipelines, you need NexaAPI — 56+ models at $0.003/image.

Installation

pip install nexaapi crewai loongsuite-instrumentation-crewai
Enter fullscreen mode Exit fullscreen mode

Python Example — CrewAI Agent with NexaAPI

from nexaapi import NexaAPI
from crewai import Agent, Task, Crew, tool

client = NexaAPI(api_key='YOUR_NEXAAPI_KEY')

@tool('Image Generator')
def generate_image(prompt: str) -> str:
    """Generate an AI image from a text prompt using NexaAPI. Returns image URL."""
    result = client.image.generate(
        model='flux-schnell',
        prompt=prompt,
        width=1024,
        height=1024
    )
    return result.url

@tool('Video Generator')
def generate_video(prompt: str) -> str:
    """Generate a short AI video from a text prompt using NexaAPI."""
    result = client.video.generate(model='kling-v1', prompt=prompt)
    return result.url

creative_agent = Agent(
    role='Creative Director',
    goal='Generate stunning visual content for marketing campaigns',
    backstory='Expert creative director using AI to produce visuals at scale.',
    tools=[generate_image, generate_video],
    verbose=True
)

task = Task(
    description='Create a product banner image for a sneaker launch with futuristic city background.',
    expected_output='URL of the generated image',
    agent=creative_agent
)

crew = Crew(agents=[creative_agent], tasks=[task])
result = crew.kickoff()
print('Generated content URL:', result)
Enter fullscreen mode Exit fullscreen mode

JavaScript Example

// npm install nexaapi
import NexaAPI from 'nexaapi';

const client = new NexaAPI({ apiKey: 'YOUR_NEXAAPI_KEY' });

async function generateImageTool(prompt) {
  const result = await client.image.generate({
    model: 'flux-schnell',
    prompt: prompt,
    width: 1024,
    height: 1024
  });
  return result.url;
}

async function runCreativeAgentPipeline() {
  const imageUrl = await generateImageTool('futuristic sneaker product banner, neon city background');
  const videoUrl = await client.video.generate({ model: 'kling-v1', prompt: 'sneaker rotating 360 degrees' }).then(r => r.url);
  return { imageUrl, videoUrl };
}

runCreativeAgentPipeline().then(console.log);
Enter fullscreen mode Exit fullscreen mode

Pricing Comparison

Provider Image Cost Models
NexaAPI $0.003 56+
Replicate ~$0.02-0.05 30+
FAL.ai ~$0.01-0.04 20+
DALL-E 3 $0.04-0.12 3

NexaAPI saves 85-97% vs competitors.

Get Started

Originally published at nexa-api.com | Source: PyPI 2026-03-27

Top comments (0)