Skip to content

Commit

Permalink
chore(docs): fix incorrect client var names (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Jul 29, 2024
1 parent 5e9ac2c commit 61625d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const client = new Anthropic({
});

async function main() {
const message = await anthropic.messages.create({
const message = await client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
model: 'claude-3-opus-20240229',
Expand All @@ -46,7 +46,7 @@ import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic();

const stream = await anthropic.messages.create({
const stream = await client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
model: 'claude-3-opus-20240229',
Expand Down Expand Up @@ -78,7 +78,7 @@ async function main() {
messages: [{ role: 'user', content: 'Hello, Claude' }],
model: 'claude-3-opus-20240229',
};
const message: Anthropic.Message = await anthropic.messages.create(params);
const message: Anthropic.Message = await client.messages.create(params);
}

main();
Expand Down Expand Up @@ -149,7 +149,7 @@ a subclass of `APIError` will be thrown:
<!-- prettier-ignore -->
```ts
async function main() {
const message = await anthropic.messages
const message = await client.messages
.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
Expand Down Expand Up @@ -198,7 +198,7 @@ const client = new Anthropic({
});

// Or, configure per-request:
await anthropic.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-opus-20240229' }, {
await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-opus-20240229' }, {
maxRetries: 5,
});
```
Expand All @@ -215,7 +215,7 @@ const client = new Anthropic({
});

// Override per-request:
await anthropic.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-opus-20240229' }, {
await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-3-opus-20240229' }, {
timeout: 5 * 1000,
});
```
Expand All @@ -237,7 +237,7 @@ import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic();

const message = await anthropic.messages.create(
const message = await client.messages.create(
{
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
Expand All @@ -259,7 +259,7 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
```ts
const client = new Anthropic();

const response = await anthropic.messages
const response = await client.messages
.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
Expand All @@ -269,7 +269,7 @@ const response = await anthropic.messages
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: message, response: raw } = await anthropic.messages
const { data: message, response: raw } = await client.messages
.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
Expand Down Expand Up @@ -381,7 +381,7 @@ const client = new Anthropic({
});

// Override per-request:
await anthropic.messages.create(
await client.messages.create(
{
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
Expand Down
6 changes: 3 additions & 3 deletions tests/api-resources/completions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import Anthropic from '@anthropic-ai/sdk';
import { Response } from 'node-fetch';

const anthropic = new Anthropic({
const client = new Anthropic({
apiKey: 'my-anthropic-api-key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource completions', () => {
test('create: only required params', async () => {
const responsePromise = anthropic.completions.create({
const responsePromise = client.completions.create({
max_tokens_to_sample: 256,
model: 'string',
prompt: '\n\nHuman: Hello, world!\n\nAssistant:',
Expand All @@ -25,7 +25,7 @@ describe('resource completions', () => {
});

test('create: required and optional params', async () => {
const response = await anthropic.completions.create({
const response = await client.completions.create({
max_tokens_to_sample: 256,
model: 'string',
prompt: '\n\nHuman: Hello, world!\n\nAssistant:',
Expand Down
6 changes: 3 additions & 3 deletions tests/api-resources/messages.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import Anthropic from '@anthropic-ai/sdk';
import { Response } from 'node-fetch';

const anthropic = new Anthropic({
const client = new Anthropic({
apiKey: 'my-anthropic-api-key',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource messages', () => {
test('create: only required params', async () => {
const responsePromise = anthropic.messages.create({
const responsePromise = client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, world' }],
model: 'claude-3-5-sonnet-20240620',
Expand All @@ -25,7 +25,7 @@ describe('resource messages', () => {
});

test('create: required and optional params', async () => {
const response = await anthropic.messages.create({
const response = await client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, world' }],
model: 'claude-3-5-sonnet-20240620',
Expand Down

0 comments on commit 61625d2

Please sign in to comment.