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

# Sample Usage

> Examples of using BLACKBOX AI API for text models

Use BLACKBOX AI's rich API for text models to directly integrate the power of AI into your applications.

# OpenAI Compatibility

BLACKBOX AI's API endpoints for text are fully compatible with OpenAI's API.

If you have an application that uses OpenAI's client libraries, you can configure it to point to BLACKBOX AI's API servers and use our models.

## Configuring OpenAI to use BLACKBOX AI's API

Pass your BLACKBOX AI API key to the `api_key` option and set the `base_url` to `https://api.blackbox.ai`:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  import os
  import openai

  client = openai.OpenAI(
      api_key=os.environ.get("BLACKBOX_API_KEY"),
      # Public api users: use https://api.blackbox.ai
      base_url="https://enterprise.blackbox.ai",
  )
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  import OpenAI from "openai";

  const client = new OpenAI({
    apiKey: process.env.BLACKBOX_API_KEY,
    // Public api users: use https://api.blackbox.ai
    baseURL: "https://enterprise.blackbox.ai",
  });
  ```
</CodeGroup>

You can find your API key in your BLACKBOX AI account settings.

## Querying a Chat Model

Query one of our [chat models](https://docs.blackbox.ai/api-reference/models/chat-models), like GPT-4:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  import os
  import openai

  client = openai.OpenAI(
      api_key=os.environ.get("BLACKBOX_API_KEY"),
      # Public api users: use https://api.blackbox.ai
      base_url="https://enterprise.blackbox.ai",
  )

  response = client.chat.completions.create(
      model="blackboxai/openai/gpt-5.5",
      messages=[
          {
              "role": "system",
              "content": "You are a helpful assistant.",
          },
          {
              "role": "user",
              "content": "What is the capital of France?",
          },
      ],
  )

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

  ```typescript TypeScript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: process.env.BLACKBOX_API_KEY,
    // Public api users: use https://api.blackbox.ai
    baseURL: 'https://enterprise.blackbox.ai',
  });

  const response = await client.chat.completions.create({
    model: 'blackboxai/openai/gpt-5.5',
    messages: [
      { role: 'user', content: 'What is the capital of France?' },
    ],
  });

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

Output:

```text theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
The capital of France is Paris.
```

## Streaming a Chat Response

Use streaming to receive responses incrementally:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  import os
  import openai

  client = openai.OpenAI(
      api_key=os.environ.get("BLACKBOX_API_KEY"),
      # Public api users: use https://api.blackbox.ai
      base_url="https://enterprise.blackbox.ai",
  )

  stream = client.chat.completions.create(
      model="blackboxai/openai/gpt-5.5",
      messages=[
          {
              "role": "system",
              "content": "You are a helpful assistant.",
          },
          {"role": "user", "content": "Explain quantum computing briefly"},
      ],
      stream=True,
  )

  for chunk in stream:
      print(chunk.choices[0].delta.content or "", end="", flush=True)
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: process.env.BLACKBOX_API_KEY,
    // Public api users: use https://api.blackbox.ai
    baseURL: 'https://enterprise.blackbox.ai',
  });

  async function run() {
    const stream = await client.chat.completions.create({
      model: 'blackboxai/openai/gpt-5.5',
      messages: [
        { role: 'system', content: 'You are a helpful assistant' },
        { role: 'user', content: 'Explain quantum computing briefly' },
      ],
      stream: true,
    });

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

  run();
  ```
</CodeGroup>

## Web Search

Access real-time information from the web using the `blackbox-search` model:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  from openai import OpenAI
  import os

  client = OpenAI(
      api_key=os.environ.get("BLACKBOX_API_KEY"),
      # Public api users: use https://api.blackbox.ai
      base_url="https://enterprise.blackbox.ai",
  )

  response = client.chat.completions.create(
      model="blackbox-search",
      messages=[
          {
              "role": "system",
              "content": "You are a helpful assistant that provides accurate, up-to-date information.",
          },
          {
              "role": "user",
              "content": "What are the latest developments from OpenAI?",
          }
      ],
  )

  print(response.choices[0].message.content)

  # Access source citations
  if hasattr(response.choices[0].message, 'annotations'):
      print("\n--- Sources ---")
      for annotation in response.choices[0].message.annotations:
          if annotation.type == 'url_citation':
              print(f"Title: {annotation.url_citation.title}")
              print(f"URL: {annotation.url_citation.url}\n")
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  import OpenAI from 'openai';

  const client = new OpenAI({
    apiKey: process.env.BLACKBOX_API_KEY,
    // Public api users: use https://api.blackbox.ai
    baseURL: 'https://enterprise.blackbox.ai',
  });

  async function main() {
    const response = await client.chat.completions.create({
      model: "blackbox-search",
      messages: [
        {
          role: "system",
          content: "You are a helpful assistant that provides accurate, up-to-date information.",
        },
        {
          role: "user",
          content: "What are the latest developments from OpenAI?",
        },
      ],
    });

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

    // Access source citations
    if (response.choices[0].message.annotations) {
      console.log("\n--- Sources ---");
      response.choices[0].message.annotations.forEach(annotation => {
        if (annotation.type === 'url_citation') {
          console.log(`Title: ${annotation.url_citation.title}`);
          console.log(`URL: ${annotation.url_citation.url}\n`);
        }
      });
    }
  }

  main();
  ```
</CodeGroup>

The `blackbox-search` model automatically searches the web and provides responses with source citations in the `annotations` field. Learn more about [Web Search](/api-reference/web-search).

<Accordion title="View Example Output">
  ```
  ### Recent Model Releases and Updates
  OpenAI has been advancing its GPT series rapidly. In mid-November 2025, they released **GPT-5.1**, described as a smarter, more conversational version of ChatGPT with improved reasoning capabilities. CEO Sam Altman has claimed that GPT-5 represents "PhD-level general intelligence," enabling complex problem-solving across domains. [[1]](https://theconversation.com/topics/openai-24920) This model supports up to 1 million token context limits in Azure OpenAI variants like GPT-4.1. [[2]](https://learn.microsoft.com/en-us/azure/ai-foundry/openai/whats-new?view=foundry-classic)

  On December 3, 2025, OpenAI announced a proof-of-concept for **GPT-5 Thinking with 'confessions'**, a technique where the model generates a secondary "confession" output admitting to any shortcuts, rule-breaking, or non-compliance in its reasoning process. This aims to increase transparency, reducing "false negatives" (hidden misbehaviors) to just 4.4% in tests. They plan to scale this with other alignment methods like chain-of-thought monitoring. [[3]](https://x.com/i/status/1996281172377436557)

  Additionally, specialized models include **GPT-5.1-Codex-Max** for agentic coding tasks, handling long-running software development, and **Aardvark**, an agentic security researcher tool. [[4]](https://www.newsbytesapp.com/news/business/openai) Azure OpenAI also launched **GPT-4.1 and GPT-4.1-nano** with enhanced function calling, async support, and conversation mode for natural interactions. [[2]](https://learn.microsoft.com/en-us/azure/ai-foundry/openai/whats-new?view=foundry-classic)

  ### Product Features and User Experience Enhancements
  ChatGPT continues to evolve with consumer-focused updates:
  - **Group chats**: Introduced in November 2025, allowing multiple users to collaborate in real-time. [[5]](https://openai.com/news/product-releases/)
  - **Integrated Voice Mode**: Rolled out on November 25, 2025, for mobile and web, enabling voice interactions within chats with real-time visuals, no separate mode required. Users can toggle back to the original setup. [[6]](https://x.com/i/status/1993381101369458763)
  - **Shopping Research**: Launched on November 24, 2025, this feature acts as an interactive buyer's guide, researching products across the web (prices, reviews, images) and personalizing based on user feedback and chat history. Usage is nearly unlimited through the holidays to aid gift shopping. [[7]](https://x.com/i/status/1993018357432586391)
  - **ChatGPT Atlas**: A new AI-powered web browser for seamless browsing within conversations. [[4]](https://www.newsbytesapp.com/news/business/openai)

  OpenAI paused app suggestions resembling ads in early December 2025 after user complaints, with Chief Research Officer Mark Chen acknowledging the misstep. Advertising initiatives, including those led by new Applications CEO Fidji Simo, have been deprioritized. [[8]](https://techcrunch.com/2025/12/07/openai-says-its-turned-off-app-suggestions-that-look-like-ads/)

  For Indian users, OpenAI made its mid-tier **ChatGPT Go** plan free for one year starting November 4, 2025, including access to GPT-5, faster responses, and higher limits—targeting its second-largest market. [[9]](https://economictimes.indiatimes.com/topic/openai)

  ### Enterprise and Adoption Growth
  Enterprise usage has surged: ChatGPT message volume grew 8x since November 2024, with custom GPTs (for workflows and institutional knowledge) jumping 19x to 20% of messages. API "reasoning tokens" increased 320x, indicating deeper AI integration—saving workers up to an hour daily. Examples include BBVA using 4,000+ custom GPTs. [[10]](https://techcrunch.com/2025/12/08/openai-boasts-enterprise-win-days-after-internal-code-red-on-google-threat/)

  New third-party apps integrated into ChatGPT include @onepeloton, @Tripadvisor, and @Target for enhanced services. [[11]](https://x.com/i/status/1993125078436135008)

  ### Acquisitions and Infrastructure
  OpenAI acquired **Neptune** (AI model tracking tools) and **Software Applications, Inc.** (AI interface for Apple devices) to bolster development. [[12]](https://www.reuters.com/technology/openai/)[[4]](https://www.newsbytesapp.com/news/business/openai) They also inked a deal with NEXTDC for an AI campus and GPU supercluster in Sydney. [[12]](https://www.reuters.com/technology/openai/)

  Funding includes SoftBank's $22.5 billion second installment in a $41 billion round. [[4]](https://www.newsbytesapp.com/news/business/openai) The **Stargate Project** advances massive AI data centers, like the Abilene, Texas facility drawing from local water sources. [[1]](https://theconversation.com/topics/openai-24920) A compute leasing deal with Oracle provides 4.5 GW of data center power. [[13]](https://www.computerworld.com/article/4015023/openai-latest-news-and-insights.html)

  ### Legal and Ethical Developments
  - A U.S. judge ordered OpenAI to produce 20 million anonymized ChatGPT logs in a copyright lawsuit from The New York Times and others, though OpenAI is appealing, citing privacy. [[12]](https://www.reuters.com/technology/openai/)
  - In India, OpenAI told the Delhi High Court that deleting ChatGPT training data would violate U.S. law amid an ANI copyright suit. [[13]](https://www.computerworld.com/article/4015023/openai-latest-news-and-insights.html)
  - A German court ruled against OpenAI, awarding damages to GEMA for unauthorized use of song lyrics in training. [[9]](https://economictimes.indiatimes.com/topic/openai)

  Internally, Altman declared a "code red" in late November 2025, prioritizing ChatGPT improvements over other projects like ads due to competition from Google. [[8]](https://techcrunch.com/2025/12/07/openai-says-its-turned-off-app-suggestions-that-look-like-ads/)

  ### Philanthropy and Community
  The OpenAI Foundation announced the first **People-First AI Fund** recipients on December 3, 2025: 208 nonprofits receiving $40.5 million in unrestricted grants to ensure AI benefits underserved communities. [[14]](https://x.com/i/status/1996258322304155695)

  For more details, check OpenAI's official newsroom or podcast episodes discussing GPT-5.1 training. [[15]](https://x.com/i/status/1995923127982019030) These developments reflect OpenAI's push toward more capable, transparent, and accessible AI amid growing scrutiny.

  --- Sources ---
  Title: 1
  URL: https://theconversation.com/topics/openai-24920

  Title: 2
  URL: https://learn.microsoft.com/en-us/azure/ai-foundry/openai/whats-new?view=foundry-classic

  Title: 3
  URL: https://x.com/i/status/1996281172377436557

  Title: 4
  URL: https://www.newsbytesapp.com/news/business/openai

  Title: 5
  URL: https://openai.com/news/product-releases/

  Title: 6
  URL: https://x.com/i/status/1993381101369458763

  Title: 7
  URL: https://x.com/i/status/1993018357432586391

  Title: 8
  URL: https://techcrunch.com/2025/12/07/openai-says-its-turned-off-app-suggestions-that-look-like-ads/

  Title: 9
  URL: https://economictimes.indiatimes.com/topic/openai

  Title: 10
  URL: https://techcrunch.com/2025/12/08/openai-boasts-enterprise-win-days-after-internal-code-red-on-google-threat/

  Title: 11
  URL: https://x.com/i/status/1993125078436135008

  Title: 12
  URL: https://www.reuters.com/technology/openai/

  Title: 13
  URL: https://www.computerworld.com/article/4015023/openai-latest-news-and-insights.html

  Title: 14
  URL: https://x.com/i/status/1996258322304155695

  Title: 15
  URL: https://x.com/i/status/1995923127982019030
  ```
</Accordion>
