> ## Documentation Index
> Fetch the complete documentation index at: https://student-213fb9fc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI SDK

> Use the OpenAI Python and Node.js SDKs with AJ STUDIOZ Cloud Infra

## Overview

AJ STUDIOZ Cloud Infra implements the full OpenAI-compatible REST API, which means you can use the official OpenAI Python and Node.js SDKs by simply changing the `base_url` / `baseURL` and your API key.

**No new SDK to install. No code rewrites.**

***

## Python

### Installation

```bash theme={null}
pip install openai
```

### Setup

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

client = OpenAI(
    base_url="https://api.ajstudioz.co.in/v1",
    api_key="YOUR_API_KEY"          # your AJ STUDIOZ API key
)
```

### Chat Completions

```python Chat theme={null}
response = client.chat.completions.create(
    model="gemma3:27b",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is the speed of light?"}
    ],
    temperature=0.7
)
print(response.choices[0].message.content)
```

### Streaming

```python Streaming theme={null}
stream = client.chat.completions.create(
    model="deepseek-v3.2",
    messages=[{"role": "user", "content": "Tell me a short story about robots."}],
    stream=True
)

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

### List Models

```python List Models theme={null}
models = client.models.list()
for m in models.data:
    print(m.id)
```

### Embeddings

```python Embeddings theme={null}
response = client.embeddings.create(
    model="gemma3:4b",
    input="The universe is enormous and full of wonder"
)
print(len(response.data[0].embedding))
```

***

## Node.js

### Installation

```bash theme={null}
npm install openai
```

### Setup

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

const client = new OpenAI({
  baseURL: "https://api.ajstudioz.co.in/v1",
  apiKey: process.env.AJSTUDIOZ_API_KEY,
});
```

### Chat Completions

```javascript Chat theme={null}
const response = await client.chat.completions.create({
  model: "gemma3:27b",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "Explain Docker in simple terms." }
  ],
  temperature: 0.7,
});

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

### Streaming

```javascript Streaming theme={null}
const stream = await client.chat.completions.create({
  model: "kimi-k2:1t",
  messages: [{ role: "user", content: "List 5 interesting facts about the ocean." }],
  stream: true,
});

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

### Embeddings

```javascript Embeddings theme={null}
const response = await client.embeddings.create({
  model: "gemma3:4b",
  input: "Machine learning enables computers to learn from data",
});

console.log(`Embedding dimensions: ${response.data[0].embedding.length}`);
```

***

## Environment Setup

<CodeGroup>
  ```bash .env theme={null}
  AJSTUDIOZ_API_KEY=your_api_key_here
  ```

  ```python Python (.env loading) theme={null}
  from dotenv import load_dotenv
  import os
  from openai import OpenAI

  load_dotenv()
  client = OpenAI(
      base_url="https://api.ajstudioz.co.in/v1",
      api_key=os.environ["AJSTUDIOZ_API_KEY"]
  )
  ```

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

  const client = new OpenAI({
    baseURL: "https://api.ajstudioz.co.in/v1",
    apiKey: process.env.AJSTUDIOZ_API_KEY,
  });
  ```
</CodeGroup>

***

## Framework Compatibility

Since AJ STUDIOZ uses the OpenAI-compatible format, it also works directly with:

| Tool                   | How to configure                    |
| ---------------------- | ----------------------------------- |
| **LangChain**          | Set `base_url` in `ChatOpenAI`      |
| **LlamaIndex**         | Set `api_base` in `OpenAI` LLM      |
| **Cursor**             | Set custom base URL in settings     |
| **Continue (VS Code)** | Configure in `config.json`          |
| **Vercel AI SDK**      | Pass `baseURL` to `createOpenAI`    |
| **AutoGen**            | Set `base_url` in `OAI_CONFIG_LIST` |

***

## Next Steps

<CardGroup cols={2}>
  <Card title="LangChain Guide" icon="link" href="/integrations/langchain">
    Full LangChain integration examples
  </Card>

  <Card title="Function Calling" icon="function" href="/guides/function-calling">
    Tool use with OpenAI SDK
  </Card>

  <Card title="Vision Guide" icon="eye" href="/guides/vision">
    Image inputs with vision models
  </Card>

  <Card title="Available Models" icon="cpu" href="/models">
    Browse all 32 available models
  </Card>
</CardGroup>
