Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.22.0"
".": "0.23.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 35
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-f95d7f3aa4164abb82f5ba3a1ccc44105e9ce85c5d2bb8f0ac58f8ef18ffc254.yml
openapi_spec_hash: 0b0cac750868ea6ba74b338888169518
config_hash: 2887483246d24a361689cbd1258db7cf
configured_endpoints: 41
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-362c03044ce6dd8119b2bf0f0f5f4972ea0506454d86ea08444c00532ddcd06e.yml
openapi_spec_hash: d7496866a5805cb1cdc927aae0076815
config_hash: e2d1be538fd1fb65bfc566a2a168cc16
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Changelog

## 0.23.0 (2025-09-19)

Full Changelog: [v0.22.0...v0.23.0](https://github.com/togethercomputer/together-typescript/compare/v0.22.0...v0.23.0)

### Features

* **api:** add evals api to config ([ce742fc](https://github.com/togethercomputer/together-typescript/commit/ce742fcb4a95e99fa2c4e9f5c479e294d8dbfc98))
* **api:** api update ([b4c3c0a](https://github.com/togethercomputer/together-typescript/commit/b4c3c0a49f56f2e50e4d9d7e87a0a1db598a56ac))
* **api:** api update ([9a5bfb7](https://github.com/togethercomputer/together-typescript/commit/9a5bfb7d5eabb6f89d8981d46b50061baef28c51))
* **api:** api update ([915a226](https://github.com/togethercomputer/together-typescript/commit/915a226ad75264493a4e67917215a02fb3bae907))
* **mcp:** add code execution tool ([c768bb9](https://github.com/togethercomputer/together-typescript/commit/c768bb9a09001ef9955a3c899e4cfc2d588350f2))


### Bug Fixes

* coerce nullable values to undefined ([f6c7e43](https://github.com/togethercomputer/together-typescript/commit/f6c7e4344493e694fc9752ff48cb976633ead25b))


### Chores

* add package to package.json ([72025f2](https://github.com/togethercomputer/together-typescript/commit/72025f28d2156a530f5ad3c41723ee3cc8706426))
* ci build action ([0f37b32](https://github.com/togethercomputer/together-typescript/commit/0f37b32dbee4ad5a5f19a6bb894f92cb2f5c36f4))
* **client:** qualify global Blob ([a9f7b6f](https://github.com/togethercomputer/together-typescript/commit/a9f7b6f6b5634630ea1978a5e362e627df8825ca))
* **deps:** update dependency @types/node to v20.17.58 ([f1839e8](https://github.com/togethercomputer/together-typescript/commit/f1839e85f502ad68c680556340d240dab3b28bd9))
* do not install brew dependencies in ./scripts/bootstrap by default ([1050534](https://github.com/togethercomputer/together-typescript/commit/1050534f4ed0420d6aaa2598211f6f505169f5f0))
* **internal:** formatting change ([0282025](https://github.com/togethercomputer/together-typescript/commit/02820255f3c707f9170d987cefb2a74124aabad3))
* **internal:** update global Error reference ([e53b252](https://github.com/togethercomputer/together-typescript/commit/e53b25217887ab211b03b93e2c09f3da4b20ef1e))
* update CI script ([99cae2f](https://github.com/togethercomputer/together-typescript/commit/99cae2f05724e68687d6c704a5b29d31dd5fa11f))

## 0.22.0 (2025-08-13)

Full Changelog: [v0.21.1...v0.22.0](https://github.com/togethercomputer/together-typescript/compare/v0.21.1...v0.22.0)
Expand Down
1 change: 1 addition & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ This affects the following methods:

- `client.endpoints.list()`
- `client.hardware.list()`
- `client.evaluations.list()`

### Removed `httpAgent` in favor of `fetchOptions`

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const client = new Together({

const chatCompletion = await client.chat.completions.create({
messages: [{ role: 'user', content: 'Say this is a test!' }],
model: 'mistralai/Mixtral-8x7B-Instruct-v0.1',
model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
});

console.log(chatCompletion.choices);
Expand All @@ -45,7 +45,7 @@ const client = new Together();

const stream = await client.chat.completions.create({
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'mistralai/Mixtral-8x7B-Instruct-v0.1',
model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
stream: true,
});
for await (const chatCompletionChunk of stream) {
Expand All @@ -70,7 +70,7 @@ const client = new Together({

const params: Together.Chat.CompletionCreateParams = {
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'mistralai/Mixtral-8x7B-Instruct-v0.1',
model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
};
const chatCompletion: Together.Chat.ChatCompletion = await client.chat.completions.create(params);
```
Expand Down Expand Up @@ -137,7 +137,7 @@ a subclass of `APIError` will be thrown:
const chatCompletion = await client.chat.completions
.create({
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'mistralai/Mixtral-8x7B-Instruct-v0.1',
model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
})
.catch(async (err) => {
if (err instanceof Together.APIError) {
Expand Down Expand Up @@ -179,7 +179,7 @@ const client = new Together({
});

// Or, configure per-request:
await client.chat.completions.create({ messages: [{ role: 'user', content: 'Say this is a test' }], model: 'mistralai/Mixtral-8x7B-Instruct-v0.1' }, {
await client.chat.completions.create({ messages: [{ role: 'user', content: 'Say this is a test' }], model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo' }, {
maxRetries: 5,
});
```
Expand All @@ -196,7 +196,7 @@ const client = new Together({
});

// Override per-request:
await client.chat.completions.create({ messages: [{ role: 'user', content: 'Say this is a test' }], model: 'mistralai/Mixtral-8x7B-Instruct-v0.1' }, {
await client.chat.completions.create({ messages: [{ role: 'user', content: 'Say this is a test' }], model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo' }, {
timeout: 5 * 1000,
});
```
Expand All @@ -222,7 +222,7 @@ const client = new Together();
const response = await client.chat.completions
.create({
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'mistralai/Mixtral-8x7B-Instruct-v0.1',
model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
})
.asResponse();
console.log(response.headers.get('X-My-Header'));
Expand All @@ -231,7 +231,7 @@ console.log(response.statusText); // access the underlying Response object
const { data: chatCompletion, response: raw } = await client.chat.completions
.create({
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'mistralai/Mixtral-8x7B-Instruct-v0.1',
model: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo',
})
.withResponse();
console.log(raw.headers.get('X-My-Header'));
Expand Down
30 changes: 30 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,33 @@ Methods:
- <code title="post /batches">client.batches.<a href="./src/resources/batches.ts">create</a>({ ...params }) -> BatchCreateResponse</code>
- <code title="get /batches/{id}">client.batches.<a href="./src/resources/batches.ts">retrieve</a>(id) -> BatchRetrieveResponse</code>
- <code title="get /batches">client.batches.<a href="./src/resources/batches.ts">list</a>() -> BatchListResponse</code>

# Evaluation

Types:

- <code><a href="./src/resources/evaluation.ts">EvaluationJudgeModelConfig</a></code>
- <code><a href="./src/resources/evaluation.ts">EvaluationModelRequest</a></code>
- <code><a href="./src/resources/evaluation.ts">EvaluationCreateResponse</a></code>
- <code><a href="./src/resources/evaluation.ts">EvaluationRetrieveResponse</a></code>
- <code><a href="./src/resources/evaluation.ts">EvaluationGetStatusResponse</a></code>
- <code><a href="./src/resources/evaluation.ts">EvaluationUpdateStatusResponse</a></code>

Methods:

- <code title="post /evaluation">client.evaluation.<a href="./src/resources/evaluation.ts">create</a>({ ...params }) -> EvaluationCreateResponse</code>
- <code title="get /evaluation/{id}">client.evaluation.<a href="./src/resources/evaluation.ts">retrieve</a>(id) -> EvaluationRetrieveResponse</code>
- <code title="get /evaluation/{id}/status">client.evaluation.<a href="./src/resources/evaluation.ts">getStatus</a>(id) -> EvaluationGetStatusResponse</code>
- <code title="post /evaluation/{id}/update">client.evaluation.<a href="./src/resources/evaluation.ts">updateStatus</a>(id, { ...params }) -> EvaluationUpdateStatusResponse</code>

# Evaluations

Types:

- <code><a href="./src/resources/evaluations.ts">EvaluationListResponse</a></code>
- <code><a href="./src/resources/evaluations.ts">EvaluationGetAllowedModelsResponse</a></code>

Methods:

- <code title="get /evaluations">client.evaluations.<a href="./src/resources/evaluations.ts">list</a>({ ...params }) -> EvaluationListResponse</code>
- <code title="get /evaluations/model-list">client.evaluations.<a href="./src/resources/evaluations.ts">getAllowedModels</a>() -> EvaluationGetAllowedModelsResponse</code>
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "together-ai",
"version": "0.22.0",
"version": "0.23.0",
"description": "The official TypeScript library for the Together API",
"author": "Together <[email protected]>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -49,8 +49,9 @@
"publint": "^0.2.12",
"ts-jest": "^29.1.0",
"ts-node": "^10.5.0",
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.8/tsc-multi.tgz",
"tsc-multi": "https://github.com/stainless-api/tsc-multi/releases/download/v1.1.9/tsc-multi.tgz",
"tsconfig-paths": "^4.0.0",
"tslib": "^2.8.1",
"typescript": "5.8.3",
"typescript-eslint": "8.31.1"
},
Expand Down
16 changes: 12 additions & 4 deletions scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
echo -n "==> Install Homebrew dependencies? (y/N): "
read -r response
case "$response" in
[yY][eE][sS]|[yY])
brew bundle
;;
*)
;;
esac
echo
}
fi

echo "==> Installing Node dependencies…"

PACKAGE_MANAGER=$(command -v yarn >/dev/null 2>&1 && echo "yarn" || echo "npm")

$PACKAGE_MANAGER install
$PACKAGE_MANAGER install "$@"
2 changes: 1 addition & 1 deletion scripts/utils/upload-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [[ "$SIGNED_URL" == "null" ]]; then
exit 1
fi

UPLOAD_RESPONSE=$(tar -cz dist | curl -v -X PUT \
UPLOAD_RESPONSE=$(tar "${BASE_PATH:+-C$BASE_PATH}" -cz "${ARTIFACT_PATH:-dist}" | curl -v -X PUT \
-H "Content-Type: application/gzip" \
--data-binary @- "$SIGNED_URL" 2>&1)

Expand Down
46 changes: 44 additions & 2 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ import {
EndpointUpdateResponse,
Endpoints,
} from './resources/endpoints';
import {
Evaluation,
EvaluationCreateParams,
EvaluationCreateResponse,
EvaluationGetStatusResponse,
EvaluationJudgeModelConfig,
EvaluationModelRequest,
EvaluationRetrieveResponse,
EvaluationUpdateStatusParams,
EvaluationUpdateStatusResponse,
} from './resources/evaluation';
import {
EvaluationGetAllowedModelsResponse,
EvaluationListParams,
EvaluationListResponse,
Evaluations,
} from './resources/evaluations';
import {
FileDeleteResponse,
FileListResponse,
Expand Down Expand Up @@ -469,7 +486,7 @@ export class Together {
const response = await this.fetchWithTimeout(url, req, timeout, controller).catch(castToError);
const headersTime = Date.now();

if (response instanceof Error) {
if (response instanceof globalThis.Error) {
const retryMessage = `retrying, ${retriesRemaining} attempts remaining`;
if (options.signal?.aborted) {
throw new Errors.APIUserAbortError();
Expand Down Expand Up @@ -776,7 +793,7 @@ export class Together {
// Preserve legacy string encoding behavior for now
headers.values.has('content-type')) ||
// `Blob` is superset of `File`
body instanceof Blob ||
((globalThis as any).Blob && body instanceof (globalThis as any).Blob) ||
// `FormData` -> `multipart/form-data`
body instanceof FormData ||
// `URLSearchParams` -> `application/x-www-form-urlencoded`
Expand Down Expand Up @@ -828,7 +845,10 @@ export class Together {
endpoints: API.Endpoints = new API.Endpoints(this);
hardware: API.Hardware = new API.Hardware(this);
batches: API.Batches = new API.Batches(this);
evaluation: API.Evaluation = new API.Evaluation(this);
evaluations: API.Evaluations = new API.Evaluations(this);
}

Together.Chat = Chat;
Together.Completions = Completions;
Together.Embeddings = Embeddings;
Expand All @@ -842,6 +862,9 @@ Together.Jobs = Jobs;
Together.Endpoints = Endpoints;
Together.Hardware = Hardware;
Together.Batches = Batches;
Together.Evaluation = Evaluation;
Together.Evaluations = Evaluations;

export declare namespace Together {
export type RequestOptions = Opts.RequestOptions;

Expand Down Expand Up @@ -961,4 +984,23 @@ export declare namespace Together {
type BatchListResponse as BatchListResponse,
type BatchCreateParams as BatchCreateParams,
};

export {
Evaluation as Evaluation,
type EvaluationJudgeModelConfig as EvaluationJudgeModelConfig,
type EvaluationModelRequest as EvaluationModelRequest,
type EvaluationCreateResponse as EvaluationCreateResponse,
type EvaluationRetrieveResponse as EvaluationRetrieveResponse,
type EvaluationGetStatusResponse as EvaluationGetStatusResponse,
type EvaluationUpdateStatusResponse as EvaluationUpdateStatusResponse,
type EvaluationCreateParams as EvaluationCreateParams,
type EvaluationUpdateStatusParams as EvaluationUpdateStatusParams,
};

export {
Evaluations as Evaluations,
type EvaluationListResponse as EvaluationListResponse,
type EvaluationGetAllowedModelsResponse as EvaluationGetAllowedModelsResponse,
type EvaluationListParams as EvaluationListParams,
};
}
6 changes: 3 additions & 3 deletions src/internal/utils/values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,21 @@ export const coerceBoolean = (value: unknown): boolean => {
};

export const maybeCoerceInteger = (value: unknown): number | undefined => {
if (value === undefined) {
if (value == null) {
return undefined;
}
return coerceInteger(value);
};

export const maybeCoerceFloat = (value: unknown): number | undefined => {
if (value === undefined) {
if (value == null) {
return undefined;
}
return coerceFloat(value);
};

export const maybeCoerceBoolean = (value: unknown): boolean | undefined => {
if (value === undefined) {
if (value == null) {
return undefined;
}
return coerceBoolean(value);
Expand Down
1 change: 1 addition & 0 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export interface ChatCompletionAssistantMessageParam {

content?: string | null;

reasoning?: string | null;
/**
* @deprecated
*/
Expand Down
Loading
Loading