> For the complete documentation index, see [llms.txt](https://openledger.gitbook.io/openledger/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://openledger.gitbook.io/openledger/product-walkthrough/api-integeration.md).

# API Integeration

OpenLedger enables seamless interaction with custom-trained large language models through secure API endpoints and a flexible chat interface. This guide outlines how developers can access, authenticate, and manage their AI agents via the OpenLedger proxy infrastructure.

### Python Integration <a href="#r528vc5zhy5b" id="r528vc5zhy5b"></a>

<figure><img src="/files/exdJPWdXWINvuymiCJaz" alt=""><figcaption></figcaption></figure>

This example demonstrates how to connect to an OpenLedger-hosted model using the OpenAI Python client.

**Usage**

* Set the base\_url to your OpenLedger proxy endpoint.
* Provide your api\_key for authorization.
* Specify the full model path, including adapter and version.

This method is recommended for backend services or scripts using Python.

### Curl <a href="#jc4tq2lz3zv5" id="jc4tq2lz3zv5"></a>

<figure><img src="/files/9ukWK13kctZ9WR311IqK" alt=""><figcaption></figcaption></figure>

This is a raw HTTP example using curl for environments where SDKs are not preferred.

**Usage**

* Define the POST request with headers for Content-Type and Authorization.
* Include your model path and message payload directly in the request body.

This method is useful for testing, automation scripts, and CLI environments.

### JavaScript / Node.js Integration <a href="#id-98mv61vxh7z7" id="id-98mv61vxh7z7"></a>

<figure><img src="/files/2sqtaGyBrgWK0VcOeVIt" alt=""><figcaption></figcaption></figure>

Use the OpenAI client library for JavaScript to integrate OpenLedger-hosted models in frontend or Node.js environments.

**Usage**

* Initialize the client with your API key and baseURL.
* Call the chat.completions.create() method with the model path and user input.
* Fully async/await compatible.

Ideal for web applications, bots, or services requiring browser-compatible interaction.

### Completion <a href="#xatjf3a9bjzw" id="xatjf3a9bjzw"></a>

With **OpenLedger**, users can:

* Build and contribute to Datanets
* Train and deploy models
* Interact and earn through tokenized chat
* Guide ecosystem direction via governance

All actions are on-chain, ensuring verifiability, transparency, and community ownership across the AI-data lifecycle.
