> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kymaapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAffiliate

> Use Kyma API with OpenAffiliate to generate affiliate content from real program data.

## What is OpenAffiliate?

[OpenAffiliate](https://openaffiliate.dev) is an open registry of 750+ affiliate programs with structured data - commission rates, cookie durations, payout terms, categories, and more. It provides a public API, CLI, and MCP server.

Combined with Kyma API, you can build content pipelines that generate reviews, comparisons, and social posts grounded in real affiliate data.

## Try It Now

The fastest way to start is [Content Lab](https://openaffiliate.dev/lab) - a ready-made tool that generates affiliate content using Kyma API and the OpenAffiliate registry.

1. Go to [openaffiliate.dev/lab](https://openaffiliate.dev/lab)
2. Search and select a program
3. Pick a content type (Top List, How-to Guide, Review, or Social Pack)
4. Paste your Kyma API key and hit Generate

Content streams in real-time. Copy the markdown and publish.

## Build Your Own Pipeline

### Step 1: Fetch Program Data

OpenAffiliate's API is public - no auth required.

<CodeGroup>
  ```javascript JavaScript theme={null}
  // Get a single program
  const program = await fetch(
    "https://openaffiliate.dev/api/programs/notion"
  ).then((r) => r.json());

  console.log(program.name);             // "Notion"
  console.log(program.commission.rate);   // "50%"
  console.log(program.cookieDays);        // 90

  // Search programs by category
  const results = await fetch(
    "https://openaffiliate.dev/api/programs?category=Productivity"
  ).then((r) => r.json());
  ```

  ```python Python theme={null}
  import httpx

  # Get a single program
  program = httpx.get(
      "https://openaffiliate.dev/api/programs/notion"
  ).json()

  print(program["name"])              # "Notion"
  print(program["commission"]["rate"])  # "50%"
  print(program["cookieDays"])         # 90

  # Search programs by category
  results = httpx.get(
      "https://openaffiliate.dev/api/programs",
      params={"category": "Productivity"}
  ).json()
  ```

  ```bash cURL theme={null}
  # Get a single program
  curl https://openaffiliate.dev/api/programs/notion

  # Search by category
  curl "https://openaffiliate.dev/api/programs?category=Productivity"
  ```
</CodeGroup>

### Step 2: Generate Content with Kyma API

Use the program data as context for content generation.

<CodeGroup>
  ```javascript JavaScript theme={null}
  import OpenAI from "openai";

  const kyma = new OpenAI({
    baseURL: "https://kymaapi.com/v1",
    apiKey: "ky-your-api-key",
  });

  // Build context from program data
  const context = `
  Product: ${program.name}
  URL: ${program.url}
  Category: ${program.category}
  Commission: ${program.commission.rate} (${program.commission.type})
  Cookie: ${program.cookieDays} days
  Description: ${program.description}
  `.trim();

  const stream = await kyma.chat.completions.create({
    model: "deepseek-v3",
    stream: true,
    messages: [
      {
        role: "system",
        content: "You are an affiliate content expert. Use ONLY the provided product data. Do not fabricate statistics or features.",
      },
      {
        role: "user",
        content: `Write a product review based on this data:\n\n${context}`,
      },
    ],
  });

  for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
  }
  ```

  ```python Python theme={null}
  from openai import OpenAI

  kyma = OpenAI(
      base_url="https://kymaapi.com/v1",
      api_key="ky-your-api-key"
  )

  context = f"""
  Product: {program['name']}
  URL: {program['url']}
  Category: {program['category']}
  Commission: {program['commission']['rate']} ({program['commission']['type']})
  Cookie: {program['cookieDays']} days
  Description: {program['description']}
  """.strip()

  stream = kyma.chat.completions.create(
      model="deepseek-v3",
      stream=True,
      messages=[
          {
              "role": "system",
              "content": "You are an affiliate content expert. Use ONLY the provided product data. Do not fabricate statistics or features.",
          },
          {
              "role": "user",
              "content": f"Write a product review based on this data:\n\n{context}",
          },
      ],
  )

  for chunk in stream:
      content = chunk.choices[0].delta.content
      if content:
          print(content, end="", flush=True)
  ```
</CodeGroup>

### Step 3: Batch Top Lists

Generate comparison articles by pulling multiple programs from the same category.

```javascript JavaScript theme={null}
// Get top Productivity programs
const programs = await fetch(
  "https://openaffiliate.dev/api/programs?category=Productivity&limit=10"
).then((r) => r.json());

const listData = programs.map(
  (p) => `- **${p.name}** (${p.url}) — ${p.commission.rate} ${p.commission.type}, ${p.cookieDays}d cookie`
).join("\n");

const response = await kyma.chat.completions.create({
  model: "deepseek-v3",
  messages: [
    {
      role: "system",
      content: "Write a top 10 listicle with a comparison table. Use ONLY the data provided.",
    },
    {
      role: "user",
      content: `Write "Top 10 Best Productivity Tools for Affiliates":\n\n${listData}`,
    },
  ],
});

console.log(response.choices[0].message.content);
```

## Model Recommendations

| Use Case                 | Model           | Why                                      |
| ------------------------ | --------------- | ---------------------------------------- |
| Reviews & listicles      | `deepseek-v3`   | Best quality-to-cost ratio for long-form |
| Social media packs       | `qwen-3.6-plus` | Most creative, best short-form prose     |
| High-volume batches      | `llama-3.3-70b` | Fastest inference speed                  |
| Structured output (JSON) | `deepseek-v3`   | Reliable JSON mode                       |

## Cost Estimate

| Content Type              | Tokens (in/out)   | Cost per piece |
| ------------------------- | ----------------- | -------------- |
| Product Review            | \~800 / \~1,200   | \~\$0.005      |
| Top 10 List               | \~1,500 / \~2,000 | \~\$0.009      |
| How-to Guide              | \~600 / \~1,500   | \~\$0.005      |
| Social Pack (4 platforms) | \~800 / \~2,000   | \~\$0.007      |

At 100 pieces/day with `deepseek-v3`: roughly **\$15-25/month**.

## OpenAffiliate Resources

* [Content Lab](https://openaffiliate.dev/lab) - Ready-made content generator
* [REST API docs](https://openaffiliate.dev/docs/api) - Full API reference
* [MCP Server](https://openaffiliate.dev/docs/mcp) - Connect AI agents to the registry
* [Program registry](https://openaffiliate.dev/programs) - Browse 750+ programs

## Next Steps

* [Content Generation Pipeline](/guides/use-cases/content-generation) - Advanced batch patterns
* [Streaming](/guides/streaming) - Handle real-time output
* [Prompt Caching](/guides/prompt-caching) - Save 90% on repeated system prompts
* [Structured Outputs](/guides/structured-outputs) - Get JSON responses for programmatic use
