//native
type Replicate = {
token: string;
};
/**
* Get a model's README
* Get the README content for a model.
Example cURL request:
```console
curl -s \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
https://api.replicate.com/v1/models/replicate/hello-world/readme
```
The response will be the README content as plain text in Markdown format:
```
# Hello World Model
This is an example model that...
```
*/
export async function main(
auth: Replicate,
model_owner: string,
model_name: string,
) {
const url = new URL(
`https://api.replicate.com/v1/models/${model_owner}/${model_name}/readme`,
);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 235 days ago