# Coding Assistant

### About

With this API, developers can seamlessly integrate various coding assistance functionalities into their applications, enabling users to write cleaner, more efficient code with ease.

This API provides a range of features tailored to support developers throughout the coding process. From code suggestion and autocomplete to syntax highlighting and error detection, the Coding Assistant API offers comprehensive support for multiple programming languages and frameworks.

Developers can leverage the API to implement intelligent code completion, enabling users to quickly find relevant suggestions as they type, thereby reducing errors and speeding up development. Additionally, the API offers syntax highlighting capabilities, making code easier to read and understand.

Furthermore, the Coding Assistant API includes features for detecting and highlighting errors in code, helping developers identify and address issues early in the development process. By providing real-time feedback on potential errors and suggesting corrections, the API helps improve code quality and reduce debugging time.

The Coding Assistant API empowers developers to build more robust and efficient applications by providing advanced coding assistance features. With its comprehensive functionality and support for multiple programming languages, the API is a valuable asset for any development workflow.

#### Developer Portal:  <https://api.market/store/magicapi/coder>

![image](https://telegra.ph/file/a69e6ca481fab26ce2c8a.png)

### Curl Requests and Responses <a href="#curl-requests-and-responses" id="curl-requests-and-responses"></a>

**Process the image**

{% tabs %}
{% tab title="Curl" %}

```bash
curl -X 'POST' \
  'https://api.magicapi.dev/api/v1/magicapi/coder/coder' \
  -H 'accept: application/json' \
  -H 'x-magicapi-key: API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "top_k": 250,
  "top_p": 0.95,
  "prompt": "Write a javascript function that calculates euclidean distance between two coordinates of any dimension",
  "max_tokens": 500,
  "temperature": 0.95,
  "system_prompt": "string",
  "repeat_penalty": 1.1,
  "presence_penalty": 0,
  "frequency_penalty": 0
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'accept': 'application/json',
    'x-magicapi-key': 'API_KEY',
    'Content-Type': 'application/json',
}

json_data = {
    'top_k': 250,
    'top_p': 0.95,
    'prompt': 'Write a javascript function that calculates euclidean distance between two coordinates of any dimension',
    'max_tokens': 500,
    'temperature': 0.95,
    'system_prompt': 'string',
    'repeat_penalty': 1.1,
    'presence_penalty': 0,
    'frequency_penalty': 0,
}

response = requests.post('https://api.magicapi.dev/api/v1/magicapi/coder/coder', headers=headers, json=json_data)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.magicapi.dev/api/v1/magicapi/coder/coder');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'accept: application/json',
    'x-magicapi-key: API_KEY',
    'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n  \"top_k\": 250,\n  \"top_p\": 0.95,\n  \"prompt\": \"Write a javascript function that calculates euclidean distance between two coordinates of any dimension\",\n  \"max_tokens\": 500,\n  \"temperature\": 0.95,\n  \"system_prompt\": \"string\",\n  \"repeat_penalty\": 1.1,\n  \"presence_penalty\": 0,\n  \"frequency_penalty\": 0\n}");

$response = curl_exec($ch);

curl_close($ch);
```

{% endtab %}

{% tab title="NodeJs" %}

```javascript
import axios from 'axios';

const response = await axios.post(
  'https://api.magicapi.dev/api/v1/magicapi/coder/coder',
  {
    'top_k': 250,
    'top_p': 0.95,
    'prompt': 'Write a javascript function that calculates euclidean distance between two coordinates of any dimension',
    'max_tokens': 500,
    'temperature': 0.95,
    'system_prompt': 'string',
    'repeat_penalty': 1.1,
    'presence_penalty': 0,
    'frequency_penalty': 0
  },
  {
    headers: {
      'accept': 'application/json',
      'x-magicapi-key': 'API_KEY',
      'Content-Type': 'application/json'
    }
  }
);
```

{% endtab %}

{% tab title="Javascript" %}

```
fetch('https://api.magicapi.dev/api/v1/magicapi/coder/coder', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'x-magicapi-key': 'API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    'top_k': 250,
    'top_p': 0.95,
    'prompt': 'Write a javascript function that calculates euclidean distance between two coordinates of any dimension',
    'max_tokens': 500,
    'temperature': 0.95,
    'system_prompt': 'string',
    'repeat_penalty': 1.1,
    'presence_penalty': 0,
    'frequency_penalty': 0
  })
});
```

{% endtab %}
{% endtabs %}

```json
{
  "request_id": REQUEST_ID
}
```

**Get the result**

{% tabs %}
{% tab title="Curl" %}

```bash
curl -X 'GET' \
  'https://api.magicapi.dev/api/v1/magicapi/coder/predictions/REQUEST_ID' \
  -H 'accept: application/json' \
  -H 'x-magicapi-key: API_KEY'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'accept': 'application/json',
    'x-magicapi-key': 'API_KEY',
}

response = requests.get('https://api.magicapi.dev/api/v1/magicapi/coder/predictions/REQUEST_ID', headers=headers)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.magicapi.dev/api/v1/magicapi/coder/predictions/REQUEST_ID');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'accept: application/json',
    'x-magicapi-key: API_KEY',
]);

$response = curl_exec($ch);

curl_close($ch);
```

{% endtab %}

{% tab title="NodeJs" %}

```javascript
import axios from 'axios';

const response = await axios.get('https://api.magicapi.dev/api/v1/magicapi/coder/predictions/REQUEST_ID', {
  headers: {
    'accept': 'application/json',
    'x-magicapi-key': 'API_KEY'
  }
});
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
fetch('https://api.magicapi.dev/api/v1/magicapi/coder/predictions/REQUEST_ID', {
  headers: {
    'accept': 'application/json',
    'x-magicapi-key': 'API_KEY'
  }
});
```

{% endtab %}
{% endtabs %}

```json
{
  "status": "succeeded",
  "result": "RESULT_URL"
}
```


---

# 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://docs.api.market/api-product-docs/magicapi/coding-assistant.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.
