Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const client = new ContextualAI({
});

async function main() {
const createAgentOutput = await client.agents.create({ name: 'xxx' });
const createAgentOutput = await client.agents.create({ name: 'Example' });

console.log(createAgentOutput.id);
}
Expand All @@ -48,7 +48,7 @@ const client = new ContextualAI({
});

async function main() {
const params: ContextualAI.AgentCreateParams = { name: 'xxx' };
const params: ContextualAI.AgentCreateParams = { name: 'Example' };
const createAgentOutput: ContextualAI.CreateAgentOutput = await client.agents.create(params);
}

Expand All @@ -66,7 +66,7 @@ a subclass of `APIError` will be thrown:
<!-- prettier-ignore -->
```ts
async function main() {
const createAgentOutput = await client.agents.create({ name: 'xxx' }).catch(async (err) => {
const createAgentOutput = await client.agents.create({ name: 'Example' }).catch(async (err) => {
if (err instanceof ContextualAI.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
Expand Down Expand Up @@ -109,7 +109,7 @@ const client = new ContextualAI({
});

// Or, configure per-request:
await client.agents.create({ name: 'xxx' }, {
await client.agents.create({ name: 'Example' }, {
maxRetries: 5,
});
```
Expand All @@ -126,7 +126,7 @@ const client = new ContextualAI({
});

// Override per-request:
await client.agents.create({ name: 'xxx' }, {
await client.agents.create({ name: 'Example' }, {
timeout: 5 * 1000,
});
```
Expand Down Expand Up @@ -178,11 +178,13 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
```ts
const client = new ContextualAI();

const response = await client.agents.create({ name: 'xxx' }).asResponse();
const response = await client.agents.create({ name: 'Example' }).asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: createAgentOutput, response: raw } = await client.agents.create({ name: 'xxx' }).withResponse();
const { data: createAgentOutput, response: raw } = await client.agents
.create({ name: 'Example' })
.withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(createAgentOutput.id);
```
Expand Down Expand Up @@ -289,7 +291,7 @@ const client = new ContextualAI({

// Override per-request:
await client.agents.create(
{ name: 'xxx' },
{ name: 'Example' },
{
httpAgent: new http.Agent({ keepAlive: false }),
},
Expand Down