An open API service indexing awesome lists of open source software.

https://github.com/adamelliotfields/api-scripts

A collection of Bash scripts for interacting with various API providers
https://github.com/adamelliotfields/api-scripts

bash curl

Last synced: 3 months ago
JSON representation

A collection of Bash scripts for interacting with various API providers

Awesome Lists containing this project

README

        

# api-scripts

A collection of Bash scripts for interacting with various API providers.

## Installation

You need some popular Rust/Go/C programs:

```sh
apt install bat fd-find fzf jq

# or

brew install bat fd fzf jq
```

## Setup

Ensure each provider has the appropriate environment variable set:

```sh
export HF_TOKEN=hf_...
export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-...
export STABILITY_API_KEY=sk-...
```

## Usage

Each script is self-contained and executable with `getopts` for portability. All use `-h` for help, for example:

```
$ ./openai/chat.sh -h

Chat with a language model

https://platform.openai.com/docs/api-reference/chat/create

Usage: chat.sh [OPTIONS]

Arguments:
The text to send to the model

Options:
-m Model to use [default: gpt-4o-mini]
-s System message to use [default: 'Be precise and concise.']
-t Maximum tokens to generate [default: 1024]
-d Dump headers to file
-u Unbuffered (streaming) output from the API
-h Print help

Environment Variables:
OPENAI_API_KEY Your OpenAI API key (required)
```

## Motivation

1. Have a working reference for various API providers.
2. Write more Bash.