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

# Start with CometAPI: create an API key and make your first call

> Start with CometAPI by creating an API key, setting the base URL, and sending your first curl, Python, or Node.js API request.

## Create an account and API key

Create a CometAPI account and API key before you call the API.

<Steps>
  <Step title="Sign in or create an account">
    Open the [CometAPI login page](https://www.cometapi.com/console/login). Continue with Google, continue with GitHub, or enter your email or username. If you do not have an account, complete account creation from this page.

    <Frame>
      <img src="https://mintcdn.com/cometapi/BtE3Lagaukxd3efj/images/overview/cometapi-console-login.png?fit=max&auto=format&n=BtE3Lagaukxd3efj&q=85&s=988bee0055bf1ce2552a8d877a48a97d" alt="CometAPI login page with Google, GitHub, and email sign-in options" width="1280" height="720" data-path="images/overview/cometapi-console-login.png" />
    </Frame>
  </Step>

  <Step title="Open API keys">
    After you sign in, open the [API key page](https://www.cometapi.com/console/token). You can also select **API Keys** in the dashboard sidebar.
  </Step>

  <Step title="Create an API key">
    Click **Create API Key**, enter a clear name such as `local-test`, and keep **Unlimited Quota** enabled for a first test unless you want to set a spending cap. Click **Create**.

    <Frame>
      <img src="https://mintcdn.com/cometapi/SZhlxZhCnMLn__BW/images/overview/810968_364191.png?fit=max&auto=format&n=SZhlxZhCnMLn__BW&q=85&s=aef81a83f29f8eb16655ed4060425f50" alt="CometAPI API keys page with the Create API Key button and create dialog highlighted" width="3824" height="1892" data-path="images/overview/810968_364191.png" />
    </Frame>
  </Step>

  <Step title="Copy the API key">
    Click the copy button in the **Key** column. Store the copied key in a server-side environment variable or a local `.env` file. Do not paste a real API key into public repositories, frontend code, screenshots, or support tickets.

    <Frame>
      <img src="https://mintcdn.com/cometapi/HhtmQffktazbxUvS/images/overview/810968_364193.png?fit=max&auto=format&n=HhtmQffktazbxUvS&q=85&s=d893f659267150d0faf45f99eb5dffc1" alt="CometAPI API keys table with the copy button highlighted for a masked API key" width="2434" height="1232" data-path="images/overview/810968_364193.png" />
    </Frame>
  </Step>
</Steps>

Request examples read `COMETAPI_KEY` from your environment.

## Store your API key locally

For local testing, export your API key as an environment variable:

```bash theme={null}
read -rsp "CometAPI API key: " COMETAPI_KEY
printf '\n'
export COMETAPI_KEY
```

## Base URL

Use this base URL for OpenAI-compatible SDKs and API calls:

```text theme={null}
https://api.cometapi.com/v1
```

## 30-second switch from OpenAI

After you have a CometAPI API key, use this two-setting diff when you switch an OpenAI SDK client to CometAPI:

```diff theme={null}
- base_url="https://api.openai.com/v1"
- api_key=os.environ["OPENAI_API_KEY"]
+ base_url="https://api.cometapi.com/v1"
+ api_key=os.environ["COMETAPI_KEY"]
```

CometAPI uses OpenAI-compatible request formats for common text, image, audio, and video workflows. If your app already uses the OpenAI SDK, start by changing the base URL and API key.

## Make your first call

After you set `COMETAPI_KEY` in your environment, replace `your-model-id` with a current model ID from the [Models page](/overview/models).

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.cometapi.com/v1/chat/completions \
    -H "Authorization: Bearer $COMETAPI_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "your-model-id",
      "messages": [
        {
          "role": "user",
          "content": "Write a one-sentence bedtime story."
        }
      ]
    }'
  ```

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

  client = OpenAI(
      api_key=os.environ["COMETAPI_KEY"],
      base_url="https://api.cometapi.com/v1",
  )

  completion = client.chat.completions.create(
      model="your-model-id",
      messages=[
          {
              "role": "user",
              "content": "Write a one-sentence bedtime story.",
          }
      ],
  )

  print(completion.choices[0].message.content)
  ```

  ```javascript Node.js theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.COMETAPI_KEY,
    baseURL: "https://api.cometapi.com/v1",
  });

  const completion = await client.chat.completions.create({
    model: "your-model-id",
    messages: [
      {
        role: "user",
        content: "Write a one-sentence bedtime story.",
      },
    ],
  });

  console.log(completion.choices[0].message.content);
  ```
</CodeGroup>

## Pick a model

Choose a model ID from the [Models page](/overview/models), then pass that value in the `model` field.

| Goal                 | Where to start                                                                                                                  |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| Chat or general text | Use a GPT, Claude, Gemini, DeepSeek, or other chat model with [Chat Completions](/api/text/chat).                               |
| Coding and reasoning | Use a coding or reasoning model with [Responses](/api/text/responses) when the model requires the Responses API.                |
| Image generation     | Use an image model with [Create image](/api/image/openai/images) or a provider-specific image guide.                            |
| Video generation     | Use a video model with the video API page that matches the provider workflow, such as [Create video](/api/video/sora-2/create). |

## What is next

* For request failures, see [Error Codes & Handling](/errors/error-codes-handling).
* For retry guidance, see [how to handle rate limits](/api/text/chat#how-to-handle-rate-limits).
* For model-specific usage, start with [Chat Completions](/api/text/chat), [Responses](/api/text/responses), [Create image](/api/image/openai/images), or [Create video](/api/video/sora-2/create).
* For billing details, see [About Pricing](/pricing/about-pricing).
* For help, see the [Help Center](/support/help-center) or contact [CometAPI support](https://www.cometapi.com/support/).

## FAQ

<AccordionGroup>
  <Accordion title="How do I create a CometAPI account?">
    Open the [CometAPI login page](https://www.cometapi.com/console/login), then continue with Google, continue with GitHub, or enter your email or username. If you do not have an account, complete account creation from the same page.
  </Accordion>

  <Accordion title="How do I get a CometAPI API key?">
    Open the [API key page](https://www.cometapi.com/console/token) in the CometAPI dashboard, click **Create API Key**, enter a name, click **Create**, and copy the generated API key. Use `$COMETAPI_KEY` in examples instead of a real API key.
  </Accordion>

  <Accordion title="Where should I store my API key?">
    Store your API key in a server-side environment variable or a local `.env` file. Do not commit it to public repositories, paste it into frontend code, include it in screenshots, or send it in support tickets.
  </Accordion>

  <Accordion title="What is the CometAPI base URL for API calls?">
    Use `https://api.cometapi.com/v1` for OpenAI-compatible SDKs and endpoints such as `/v1/chat/completions`.
  </Accordion>

  <Accordion title="Does CometAPI work with the OpenAI Python SDK?">
    Yes. Create an `OpenAI` client, set `api_key` to your CometAPI API key, and set `base_url` to `https://api.cometapi.com/v1`.
  </Accordion>

  <Accordion title="How do I switch from OpenAI to CometAPI?">
    Change the base URL to `https://api.cometapi.com/v1`, replace the API key with your CometAPI API key, and use a CometAPI model ID from the [Models page](/overview/models).
  </Accordion>

  <Accordion title="Which model ID should I use first?">
    Choose the model ID by use case. Start from the [Models page](/overview/models), then select a chat, coding, image, or video model that matches the API page that you plan to call.
  </Accordion>

  <Accordion title="Which programming languages does CometAPI support?">
    CometAPI works with any programming language that can send HTTPS requests. Start with the curl, Python, and Node.js examples on this page, or use an OpenAI-compatible SDK that lets you override the base URL.
  </Accordion>

  <Accordion title="Does CometAPI offer a free trial or free API key?">
    You can create a CometAPI API key from the dashboard. To check free trial availability, free trial credits, and billing details, see the [CometAPI pricing page](https://www.cometapi.com/pricing/) and [About Pricing](/pricing/about-pricing).
  </Accordion>
</AccordionGroup>

<script type="application/ld+json">
  {`
    {
    "@context": "https://schema.org",
    "@graph": [
      {
        "@type": "HowTo",
        "name": "CometAPI quickstart: Create an API key and make your first call",
        "description": "CometAPI quickstart for first-time users: sign in, create an API key, copy the key, set the base URL, and make your first curl, Python, or Node.js API call.",
        "step": [
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/overview/quick-start#sign-in-or-create-an-account",
            "name": "Sign in or create an account",
            "text": "Open https://www.cometapi.com/console/login and continue with Google, GitHub, or email."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/overview/quick-start#open-api-keys",
            "name": "Open API keys",
            "text": "After signing in, open https://www.cometapi.com/console/token or select API Keys in the dashboard sidebar."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/overview/quick-start#create-an-api-key",
            "name": "Create an API key",
            "text": "Click Create API Key, enter a name, choose the quota setting, and click Create."
          },
          {
            "@type": "HowToStep",
            "@id": "https://apidoc.cometapi.com/overview/quick-start#copy-the-api-key",
            "name": "Copy the API key",
            "text": "Click the copy button in the Key column and store the key in a server-side environment variable or local .env file."
          },
          {
            "@type": "HowToStep",
            "name": "Set the base URL",
            "text": "Use https://api.cometapi.com/v1 as the base URL for OpenAI-compatible SDKs and API calls."
          },
          {
            "@type": "HowToStep",
            "name": "Make your first call",
            "text": "Call /v1/chat/completions with curl, Python, or Node.js, and replace your-model-id with a current model ID from the CometAPI Models page."
          }
        ]
      },
      {
        "@type": "FAQPage",
        "mainEntity": [
          {
            "@type": "Question",
            "name": "How do I create a CometAPI account?",
            "acceptedAnswer": {
              "@type": "Answer",
              "text": "Open the CometAPI login page and continue with Google, GitHub, or email. If you do not have an account, complete account creation from the same page."
            }
          },
          {
            "@type": "Question",
            "name": "How do I get a CometAPI API key?",
            "acceptedAnswer": {
              "@type": "Answer",
              "text": "Open the API key page in the CometAPI dashboard, click Create API Key, enter a name, click Create, and copy the generated API key."
            }
          },
          {
            "@type": "Question",
            "name": "Where should I store my API key?",
            "acceptedAnswer": {
              "@type": "Answer",
              "text": "Store your API key in a server-side environment variable or a local .env file. Do not commit it to public repositories, paste it into frontend code, include it in screenshots, or send it in support tickets."
            }
          },
          {
            "@type": "Question",
            "name": "What is the CometAPI base URL for API calls?",
            "acceptedAnswer": {
              "@type": "Answer",
              "text": "Use https://api.cometapi.com/v1 for OpenAI-compatible SDKs and endpoints."
            }
          },
          {
            "@type": "Question",
            "name": "Does CometAPI work with the OpenAI Python SDK?",
            "acceptedAnswer": {
              "@type": "Answer",
              "text": "Yes. Create an OpenAI client, set api_key to your CometAPI API key, and set base_url to https://api.cometapi.com/v1."
            }
          },
          {
            "@type": "Question",
            "name": "How do I switch from OpenAI to CometAPI?",
            "acceptedAnswer": {
              "@type": "Answer",
              "text": "Change the base URL to https://api.cometapi.com/v1, replace the API key with your CometAPI API key, and use a CometAPI model ID from the Models page."
            }
          },
          {
            "@type": "Question",
            "name": "Which model ID should I use first?",
            "acceptedAnswer": {
              "@type": "Answer",
              "text": "Choose the model ID by use case. Start from the Models page, then select a chat, coding, image, or video model that matches the API page that you plan to call."
            }
          },
          {
            "@type": "Question",
            "name": "Which programming languages does CometAPI support?",
            "acceptedAnswer": {
              "@type": "Answer",
              "text": "CometAPI works with any programming language that can send HTTPS requests. Start with the curl, Python, and Node.js examples, or use an OpenAI-compatible SDK that lets you override the base URL."
            }
          },
          {
            "@type": "Question",
            "name": "Does CometAPI offer a free trial or free API key?",
            "acceptedAnswer": {
              "@type": "Answer",
              "text": "You can create a CometAPI API key from the dashboard. To check free trial availability, free trial credits, and billing details, see the CometAPI pricing page and About Pricing page."
            }
          }
        ]
      }
    ]
    }
    `}
</script>
