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

# Beitragstext generieren

> Erstellen Sie mithilfe von KI einen neuen Social-Media-Beitrag

export const HeaderAPI = ({noProfileKey, profileKeyRequired}) => <>
    <ParamField header="Authorization" type="string" required>
      <a href="/apis/overview#authorization">API Key</a> of the Primary Profile.
      <br />
      <br />
      Format: <code>Authorization: Bearer API_KEY</code>
    </ParamField>
    {!noProfileKey && (profileKeyRequired ? <ParamField header="Profile-Key" type="string" required>
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField> : <ParamField header="Profile-Key" type="string">
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

export const PlansAvailable = ({plans = [], maxPackRequired}) => {
  let displayPlans = plans;
  if (plans && plans.length === 1) {
    const lowerCasePlan = plans[0].toLowerCase();
    if (lowerCasePlan === "business") {
      displayPlans = ["Launch", "Business", "Enterprise"];
    } else if (lowerCasePlan === "premium") {
      displayPlans = ["Premium", "Launch", "Business", "Enterprise"];
    }
  }
  return <Note>
Available on {displayPlans.length === 1 ? "the " : ""}
{displayPlans.join(", ").replace(/\b\w/g, l => l.toUpperCase())}{" "}
{displayPlans.length > 1 ? "plans" : "plan"}.

{maxPackRequired && <span onClick={() => window.open('https://www.ayrshare.com/docs/additional/maxpack', '_self')} className="flex items-center mt-2 cursor-pointer">
 <span className="px-1.5 py-0.5 rounded text-sm" style={{
    backgroundColor: '#C264B6',
    color: 'white',
    fontSize: '12px'
  }}>
   Max Pack required
 </span>
</span>}
</Note>;
};

<PlansAvailable plans={["premium"]} maxPackRequired={true} />

Erstellen Sie mithilfe von KI einen neuen Social-Media-Beitrag. Sie können entweder Text oder Bilder bereitstellen, um den Social-Media-Beitrag zu erstellen. Es gelten [Token-Limits](/apis/generate/overview#token-limits).

## Header-Parameter

<HeaderAPI noProfileKey />

## Body-Parameter

<ParamField body="text" type="string" required>
  Beschreibung dessen, worum es im Beitrag gehen soll. Zum Beispiel: „Ein Schuhverkauf am Montag mit Sonderangeboten für rote, blaue und gelbe Schuhe.“ Nicht erforderlich, wenn der Parameter `mediaUrls` enthalten ist.
</ParamField>

<ParamField body="mediaUrls" type="array">
  Ein Array von Bild-URLs, auf denen der Beitragstext basieren soll. Erforderlich, wenn der Parameter `text` nicht enthalten ist.
</ParamField>

<ParamField body="hashtags" type="boolean" default={true}>
  Fügen Sie dem Beitrag Hashtags hinzu.
</ParamField>

<ParamField body="emojis" type="boolean" default={false}>
  Fügen Sie dem Beitrag Emojis hinzu.
</ParamField>

<ParamField body="twitter" type="boolean" default={false}>
  Erstellen Sie einen Beitrag mit 280 oder weniger Zeichen.
</ParamField>

<RequestExample>
  ```bash cURL theme={"system"}
  curl \
  -H "Authorization: Bearer API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"text": "This beautiful new shoe is on sale now. It comes in red, blue, or purple. Check it out today."}' \
  -X POST https://api.ayrshare.com/api/generate/post
  ```

  ```javascript JavaScript theme={"system"}
  const API_KEY = "API_KEY";

  fetch("https://api.ayrshare.com/api/generate/post", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "Authorization": `Bearer ${API_KEY}`
        },
        body: JSON.stringify({
          post: "This beautiful new shoe is on sale now. It comes in red, blue, or purple. Check it out today.", // required
        }),
      })
        .then((res) => res.json())
        .then((json) => console.log(json))
        .catch(console.error);
  ```

  ```python Python theme={"system"}
  import requests

  payload = {'post': 'This beautiful new shoe is on sale now. It comes in red, blue, or purple. Check it out today.'}
  headers = {'Content-Type': 'application/json',
          'Authorization': 'Bearer API_KEY'}

  r = requests.post('https://api.ayrshare.com/api/generate/post',
      json=payload,
      headers=headers)

  print(r.json())
  ```

  ```php PHP theme={"system"}
  <?php

  $curl = curl_init();
  $data = array (
    "post" => "This beautiful new shoe is on sale now. It comes in red, blue, or purple. Check it out today."
  );

  curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api.ayrshare.com/api/generate/post',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => http_build_query($data),
    CURLOPT_HTTPHEADER => array(
      'Authorization: Bearer API_KEY',
      'Accept-Encoding: gzip'
    ),
  ));

  $response = curl_exec($curl);
  curl_close($curl);
  echo $response;
  ```
</RequestExample>

<ResponseExample>
  ```json 200: Text theme={"system"}
  {
      "status": "success",
      "post": "🎉🛍️ Introducing the stunning new shoes that's now on sale! You can choose from three different colors – red, blue, or purple – and trust us, they're all amazing! Don't miss out on this beauty and grab yours today! 🙌 #newshoe #onSale #fashionable #colormebeautiful 🌈",
      "usage": 98,                // Tokens used for this call
      "totalMonthlyUsage": 733    // Total tokens used for the month
  }
  ```

  ```json 200: Image theme={"system"}
  {
    "status": "success",
    "post": ["Ventured out on a serene walk today—a path less traveled but surrounded by the lush vibrancy of nature's finest. The perfect spot to reconnect with the earth and oneself. Where do your paths lead you?\n\n#NatureWalks #ExploreOutdoors #PeacefulPath"],
    "mediaUrls": ["https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg", "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"],
    "usage": 2295,
    "totalMonthlyUsage": 6987
  }
  ```

  ```json 400: Bad Request theme={"system"}
  {
    "action": "request",
    "status": "error",
    "code": 101,
    "message": "Missing or incorrect parameters. Please verify with the docs. .../ayrshare.com/rest-api/endpoints"
  }
  ```
</ResponseExample>
