← Back to MarketOS

MarketOS API

Generate marketing content programmatically. BYOK — bring your own Gemini key, we handle the orchestration.

BYOK Philosophy: MarketOS never marks up AI costs. You provide your own Google Gemini API key — that's the only required key. Existing plan holders ($19.99/mo or $199 lifetime) get API access included with 1,000 requests/day. API-only users pay per-request via x402 protocol: $0.05 for generation endpoints, $0.01 for lightweight calls. Your AI provider costs go directly to Google at zero markup.

Quick Start

1. Get a Gemini API Key

Visit Google AI Studio, sign in, and create an API key. Free tier available with generous limits.

2. Make Your First Request

No account needed — use stateless BYOK mode:

curl -X POST https://marketos.org/api/v1/generate/caption \
  -H "Content-Type: application/json" \
  -H "X-Api-Keys: $(echo '{"gemini":"YOUR_GEMINI_KEY"}' | base64)" \
  -d '{
    "prompt": "New product launch for our coffee brand",
    "platform": "instagram"
  }'

3. Or Register for a Token

If you have a MarketOS license, register your keys once:

curl -X POST https://marketos.org/api/api-keys/register \
  -H "Content-Type: application/json" \
  -d '{
    "licenseKey": "MOS_XXXX-XXXX-XXXX-XXXX",
    "apiKeys": { "gemini": "YOUR_GEMINI_KEY" }
  }'

Then use the returned mos_xxx token in all requests:

Authorization: Bearer mos_xxxxxxxxxxxx

Authentication

Four authentication methods are supported, checked in this order:

MethodHeaderDescription
Stateless BYOK X-Api-Keys: <base64> Pass keys per request as base64-encoded JSON. Never stored. Maximum privacy.
Plan Holder Authorization: Bearer sub_xxx or lt_xxx Existing MarketOS subscribers (sub_) or lifetime license holders (lt_). API access included with 1,000 requests/day.
Registered BYOK Authorization: Bearer mos_xxx Register keys once via /api/api-keys/register. Keys encrypted at rest (AES-256-GCM). Convenient for agents.
x402 Payment X-PAYMENT: <signed payload> Pay per request with USDC on Base. No account or signup needed. Include X-Api-Keys header alongside for your Gemini key.
Required key: gemini — your Google Gemini API key. This is the only required AI provider key.
Optional key: jina — Jina Reader API key for enhanced scraping (the scrape endpoint works without it, but a Jina key removes rate limits).

Endpoints

POST /api/v1/generate/marketing
Full pipeline: parse intent → generate image → generate caption + hashtags. The one-shot endpoint for AI agents.
ParameterTypeRequiredDescription
promptstringYesMarketing brief (e.g. "Instagram post for our new espresso blend")
brandContextstringNoBrand summary from /api/v1/scrape
platformstringNoinstagram | linkedin | twitter | tiktok | general (default: instagram)
imageModelstringNoImage model ID (default: imagen-4.0-generate-001). See Image Models below.
aspectRatiostringNo1:1 | 16:9 | 9:16 | 4:3 | 3:4 (default: 1:1)
stylestringNoVisual style description (e.g. "minimalist flat illustration")
languagestringNoISO language code or auto (default: auto)
skipImagebooleanNoSkip image generation for faster caption-only response

Returns: { image?, caption, hashtags, platform, imagePrompt, enhancedBrief, imageError? }

POST /api/v1/generate/caption
Generate social media captions and hashtags. Uses Gemini Flash Lite for fast, cost-effective generation.
ParameterTypeRequiredDescription
promptstringYesWhat the caption should be about
platformstringNoinstagram | linkedin | twitter | tiktok | general (default: instagram)
brandContextstringNoBrand summary for tone matching
hashtagThemesstring[]NoBroad themes for hashtag generation (default: ["marketing"])
expandedbooleanNoGenerate longer caption (5-8 sentences) with up to 25 hashtags
languagestringNoISO language code or auto

Returns: { caption, hashtags, platform }

POST /api/v1/generate/content
Generate blog posts, SEO content, educational articles, and 100+ content types. Uses Gemini Flash Lite.
ParameterTypeRequiredDescription
topicstringNoTopic to write about. Auto-generated from brand context if omitted.
contentTypestringNoContent type ID (default: blog-standard). See /api/v1/info for full list of 40+ types.
wordCountstringNoshort (~300) | medium (~600) | long (~1000) | extended (~1500). Default: medium
brandContextstringNoBrand summary for tone and industry matching
languagestringNoISO language code or auto

Returns: { title, content, topic, contentType, wordCount }

POST /api/v1/generate/image
Generate marketing images using Google Imagen and Gemini image models.
ParameterTypeRequiredDescription
promptstringYesImage description or marketing brief
modelstringNoImage model ID (default: imagen-4.0-generate-001). See Image Models below.
aspectRatiostringNo1:1 | 16:9 | 9:16 | 4:3 | 3:4 (default: 1:1). Imagen models only.
numberOfImagesnumberNo1–4 images per request (default: 1). Imagen models only.
brandContextstringNoBrand context appended to prompt (first 500 chars)
stylestringNoVisual style description appended to prompt

Returns: { images: [{ base64, mimeType }], model, prompt }

Image Models

Model IDNameNotes
imagen-4.0-generate-001Imagen 4Default. High quality, supports aspect ratio and multi-image.
imagen-4.0-fast-generate-001Imagen 4 FastFaster generation, slightly lower quality.
imagen-4.0-ultra-generate-001Imagen 4 UltraHighest quality. Best for hero images.
gemini-2.5-flash-imageGemini 2.5 Flash ImageGemini-based. No aspect ratio or multi-image support.
gemini-3-pro-image-previewGemini 3 Pro ImageGemini-based. Preview model.
POST /api/v1/scrape
Extract brand context from any URL using Jina Reader + Gemini summarization. Chain the output as brandContext in generation endpoints.
ParameterTypeRequiredDescription
urlstringYesWebsite URL to scrape (auto-prefixed with https:// if missing)
existingContextstringNoExisting brand context to merge with new scrape results

Returns: { url, title, tagline, description, content }

Tip: The content field in the response is an 800–1200 word brand summary. Pass it directly as brandContext to any generation endpoint for brand-aligned output. Scrape multiple pages and use existingContext to build a comprehensive brand profile.
GET /api/v1/info
Machine-readable API capabilities, content types, image models, pricing, and auth methods. No authentication required.

Returns the full API schema including all 40+ content types, image models, word count options, platform list, rate limits, pricing, and agent skill references. Ideal for AI agent discovery.

Example: Full Agent Workflow

An AI agent can chain these endpoints to generate branded content:

// Step 1: Extract brand context
POST /api/v1/scrape
{ "url": "https://coffeeshop.com" }
→ { "content": "Premium artisan coffee roaster...", "title": "...", ... }

// Step 2: Generate complete marketing post
POST /api/v1/generate/marketing
{
  "prompt": "Instagram post for our new espresso blend",
  "brandContext": "Premium artisan coffee roaster...",
  "platform": "instagram"
}
→ {
  "image": { "base64": "...", "mimeType": "image/png" },
  "caption": "Every cup tells a story ☕...",
  "hashtags": ["coffee", "espresso", ...],
  "platform": "instagram",
  "imagePrompt": "...",
  "enhancedBrief": "..."
}

// Or generate individual pieces:
POST /api/v1/generate/caption
{ "prompt": "New espresso blend launch", "platform": "twitter" }

POST /api/v1/generate/content
{ "topic": "Why single-origin matters", "contentType": "blog-standard", "wordCount": "long" }

POST /api/v1/generate/image
{ "prompt": "Steaming espresso cup, morning light", "model": "imagen-4.0-generate-001" }

Pricing

PlanAPI AccessDaily QuotaCost
SubscriptionIncluded1,000 req/day$19.99/month
Lifetime LicenseIncluded1,000 req/day$199 one-time
API-Only (x402)Pay per requestUnlimited$0.05 generation / $0.01 lightweight
AI costs are always BYOK: You pay Google directly for Gemini usage via your own API key. MarketOS charges only for orchestration (the pipeline logic, prompt engineering, and infrastructure). Zero markup on AI provider costs, ever.

Per-Request Fees (x402)

EndpointFeeCategory
/api/v1/generate/marketing$0.05Generation
/api/v1/generate/image$0.05Generation
/api/v1/generate/content$0.05Generation
/api/v1/generate/caption$0.01Lightweight
/api/v1/scrape$0.01Lightweight

Rate Limits

30 requests per minute per token or IP. Responses include Retry-After header when limited. Plan holders have a separate 1,000 requests/day quota that resets at midnight UTC.

Errors

StatusMeaning
400Bad request — missing or invalid parameters
401Authentication failed — invalid token or API key
402Payment required — x402 payment needed (no plan token provided). Response includes X-PAYMENT-REQUIRED header with payment details.
403Forbidden — inactive or expired license
422Unprocessable — content filtered by safety systems
429Rate limited — wait and retry (check Retry-After header)
500Server error
502Upstream error — external API (Gemini, Jina) failed

x402 Protocol Support

MarketOS supports the x402 payment protocol for autonomous AI agent payments. No signup, no API keys, no merchant account needed.

How It Works

1. Agent sends request without auth
   → Server responds 402 with X-PAYMENT-REQUIRED header

2. Agent reads payment requirements from header:
   - Amount (e.g., 0.05 USDC)
   - Wallet address
   - Network (Base mainnet)

3. Agent signs USDC payment on Base blockchain

4. Agent retries request with:
   - X-PAYMENT header (signed payment payload)
   - X-Api-Keys header (base64 Gemini key for BYOK)

5. Server verifies payment via Coinbase facilitator
   → Returns the generated content

Payments are in USDC on Base (Ethereum L2). The Coinbase facilitator verifies payments at no cost to either party. Agents using x402-compatible wallets can pay autonomously without human intervention.

For agent developers: The GET /api/v1/info endpoint returns full payment details including the wallet address, network, and facilitator URL. Your agent can discover everything it needs programmatically.

AI Provider

All API endpoints use Google Gemini exclusively:

Use CaseModel
Caption generationgemini-flash-lite-latest
Content generationgemini-flash-lite-latest
Intent parsing (marketing pipeline)gemini-flash-lite-latest
Brand context summarizationgemini-flash-lite-latest
Image generationImagen 4 / Gemini image models (see table above)

The scrape endpoint also uses Jina Reader API for web content extraction. A Jina API key is optional but recommended for higher rate limits.

Agent Discovery

MarketOS provides multiple discovery mechanisms for AI agents:

ResourceURLPurpose
llms.txt/llms.txtConcise API overview for LLMs
llms-full.txt/llms-full.txtDetailed API reference for LLMs
SKILL.md/skills/marketos/SKILL.mdAgent skill definition (OpenClaw compatible)
API Info/api/v1/infoMachine-readable JSON with full capabilities