# carter-js

## Prerequisites

In order to use `carter-js` you'll need to sign up to sign up to [CarterAPI](https://www.carterapi.com/) and create an agent. CarterAPI has excellent documentation.

## Installation

*`` `npm install carter-js` ``*

## The Carter Object

The main component of `carter-js` is the `Carter` object. This object provides a set of methods to interact with your carter agent, create useful skills, track the conversation history and analyse your agent's response times.

```javascript
import Carter from 'carter-js'

const carter = new Carter(apiKey, userLogger, speak) // Only API key is mandatory
```

It is important to remember to use the `new` keyword in order to create an instance of the Carter object. Pass in the apiKey of your specific agent - remember to keep this secret while developing and in production as this will allow anyone access to your agent.

You can also pass in a logger object. This feature is in beta and is untested, but provided the logger as debug, info, warn and error functions attached, it will log interactions with your carter agent to the relevant log levels.

### Speak

Carter's audio URL can cause some latency, and can therefore be toggled at a Class and Function level. Passing the `speak` boolean will set the default behaviour of your object. This will be used when calling any functions on the object, unless otherwise specified in the function call.


---

# 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://lazylyrics.gitbook.io/carter-js-v4/carter-js.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.
