> For the complete documentation index, see [llms.txt](https://docs.anyone.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.anyone.io/sdk/integrations/proxy-ai-api.md).

# Proxy AI API Request

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

1. Install the anyone-client [npm](https://www.npmjs.com/package/@anyone-protocol/anyone-client) package:

{% code overflow="wrap" %}

```bash
npm install @anyone-protocol/anyone-client
```

{% endcode %}

2. Save the code to file `sendrequest.js` and edit highlighted `const` variables to match your API.
   1. `const API_URL = 'https://inference.asicloud.cudos.org/v1/chat/completions';`&#x20;
   2. `const PROVIDER_API_KEY = 'PROVIDER_API_KEY';`
   3. `const MODEL = 'asi1-mini';`
   4. `const MESSAGE = 'Hello Anyone!';`

{% code expandable="true" %}

```js
const { Process, Socks } = require('@anyone-protocol/anyone-client');

async function main() {
    try {
        // Start the anyone-client proxy
        const anon = new Process({ displayLog: false, socksPort: 9050 });
        const socks = new Socks(anon);
        await anon.start();

        const API_URL = 'https://inference.asicloud.cudos.org/v1/chat/completions';
        const PROVIDER_API_KEY = 'PROVIDER_API_KEY';
        const MODEL = 'asi1-mini';
        const MESSAGE = 'Hello Anyone!';

        // Create the JSON payload
        const payload = {
            model: MODEL,
            messages: [
                {
                    role: 'user',
                    content: MESSAGE,
                },
            ],
        };

        // Set up the API request headers
        const headers = {
            Authorization: `Bearer ${PROVIDER_API_KEY}`,
            'Content-Type': 'application/json',
        };

        // Make the request
        const response = await socks.post(API_URL, payload, { headers });
        console.log(`\nSending: ${payload.content, ( MESSAGE )}`);

        // Extract and log the response
        console.log(`\nResponse: ${JSON.stringify(response.data.choices[0].message.content, null, 2)}\n`);

        // Stop the anyone-client proxy
        await anon.stop();

    } catch (error) {
        console.error('Error:', error);
    }
}

main();
```

{% endcode %}

3. Run the script: `node sendrequest.js`

<figure><img src="/files/tFsTUeHXuZNRLZf0bHKY" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.anyone.io/sdk/integrations/proxy-ai-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
