# Quickstart

## Generating an API Key

To get started with the KidJig API, please create an account and generate your unique API Key. This key will grant you access to our powerful AI functionalities.

**Follow this above steps**:

1. <mark style="color:blue;">**Create an Account**</mark>:  **Visit the** [**Kidjig API**](https://platform.kidjig.com/)  **website and sign up for an account.**
2. <mark style="color:blue;">**Generate Your  API Key**</mark>**:**   After logging in, navigate to the [<mark style="color:blue;">**API Keys**</mark>](https://platform.kidjig.com/api-keys) section and click on <mark style="color:orange;">**Generate API Key**</mark> to create your unique key.**.**

### **Configure Base URL** <a href="#configure-base-url" id="configure-base-url"></a>

Depending on your environment and application, you will need to set the base URL accordingly. Below is the universal string you can use to access our API:&#x20;

```bash
https://api.kidjig.com/provider
```

{% hint style="info" %} <mark style="color:green;">Feel free to copy this URL now or return to it later when you're ready to configure your environment or application.</mark>
{% endhint %}

## Making Your First API Call

Depending on your development environment, the method for calling our API may vary. Below are examples of how to make your first API call using two popular programming languages: **Python** and **Node.js**.

### REST API

## Authorization

KidJig API authorization is based on an API key rather than a Bearer token. To access the API, you need to include your API key in the <mark style="color:orange;">`X-Api-Key`</mark> HTTP header within your request.:

{% code fullWidth="false" %}

```bash
X-Api-Key: Kidjig Api_Key
```

{% endcode %}

{% hint style="info" %}
Make sure to replace `your_api_key` with the actual API key you received upon account creation.
{% endhint %}

### Request Example

Once your API key is ready, you can call our API using standard HTTP methods. Below is an example of how to make a request to the KidJig API.

KidJig offers two flexible integration methods for chat completion:

1. Direct REST API Integration

**Example HTTP Request**

**Endpoint:**

{% code overflow="wrap" %}

```bash
POST https://api.kidjig.com/provider/api/v1/{provider}/chat/completions
```

{% endcode %}

**Headers:**

```bash
X-Api-Key: your_api_key
Content-Type: application/json
```

**Request Body:**

```bash
{
    "model": "modelId String"
    "prompt": "What is the capital of France?",
    "stream": false,
    "config": {
        "temperature": 0.7,
        "maxOutputTokens": 4096,
        "topP": 1,
        "topK": 40
    }
}
```

{% hint style="info" %}
Make sure to replace `{provider}` and `{model}` with the appropriate values, and substitute `your_api_key` with your actual API key.
{% endhint %}

{% tabs %}
{% tab title="JavaScript" %}
{% code overflow="wrap" fullWidth="false" %}

```javascript
const axios = require('axios');

const base_url = "https://api.kidjig.com/provider/api/v1/{provider}/chat/completions";
const headers = {
    "X-Api-Key": "your_api_key", // kidjig_api_key
    "Content-Type": "application/json"
};
const data = {
    "model": "modelId String"
    "prompt": "What is the capital of France?",
    "stream": false,
    "config": {
        "temperature": 0.7,
        "maxOutputTokens": 4096,
        "topP": 1,
        "topK": 40
    }
};

axios.post(base_url, data, { headers })
    .then(response => console.log(response.data))
    .catch(error => console.error(error));
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import requests

url = "https://api.kidjig.com/provider/api/v1/{provider}/chat/completions"
headers = {
    "X-Api-Key": "your_api_key", #kidjig_api_key
    "Content-Type": "application/json"
}
data = {
    "model": "modelId String"
    "prompt": "What is the capital of France?",
    "stream": False,
    "config": {
        "temperature": 0.7,
        "maxOutputTokens": 4096,
        "topP": 1,
        "topK": 40
    }
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 2.  OpenAI-Compatible Client Integration

```bash
client = OpenAI(
    base_url="https://api.kidjig.com/provider/api/v1/{provider}",
    api_key="your_api_key"
)

completion = client.chat.completions.create(
    model="string",  # modelId or modelName
    messages=[{"role": "user", "content": "Hello!"}]
)
```

### Response  Example

Regardless of the programming language you use (Python, JavaScript, etc.), the response schema from the KidJig API will remain consistent. Below is the standard response format you can expect:

```bash
{
    "success": true,
    "statusCode": 200,
    "request": {
        "ip": "::ffff:172.20.0.6",
        "method": "POST",
        "url": "/api/v1/{provider}/chat/{model}"
    },
    "message": "Completion generated successfully",
    "data": {
        "id": "msg_xyz123",
        "model": "{model}",
        "content": "The capital of France is Paris.",
        "usage": {
            "promptTokens": 12,
            "completionTokens": 180,
            "totalTokens": 192
        },
        "cost": 0.006
    }
}
```

## Next Steps

{% hint style="info" %}
[Learn how to use Text Model LLM](/kidjig-docs/api-provider/text-models-llm.md)
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kidjig.gitbook.io/kidjig-docs/getting-started/quickstart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
