Skip to content

Commit

Permalink
docs(readme): remove old migration guide (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Dec 19, 2023
1 parent 4ffbcdf commit eec4574
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,6 @@ and offers both synchronous and asynchronous clients powered by [httpx](https://

For the AWS Bedrock API, see [`anthropic-bedrock`](https://github.com/anthropics/anthropic-bedrock-python).

## Migration from v0.2.x and below

In `v0.3.0`, we introduced a fully rewritten SDK.

The new version uses separate sync and async clients, unified streaming, typed params and structured response objects, and resource-oriented methods:

**Sync before/after:**

```diff
- client = anthropic.Client(os.environ["ANTHROPIC_API_KEY"])
+ client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])
# or, simply provide an ANTHROPIC_API_KEY environment variable:
+ client = anthropic.Anthropic()

- rsp = client.completion(**params)
- rsp["completion"]
+ rsp = client.completions.create(**params)
+ rsp.completion
```

**Async before/after:**

```diff
- client = anthropic.Client(os.environ["ANTHROPIC_API_KEY"])
+ client = anthropic.AsyncAnthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

- await client.acompletion(**params)
+ await client.completions.create(**params)
```

The `.completion_stream()` and `.acompletion_stream()` methods have been removed;
simply pass `stream=True`to `.completions.create()`.

Streaming responses are now incremental; the full text is not sent in each message,
as v0.3 sends the `Anthropic-Version: 2023-06-01` header.

<details>
<summary>Example streaming diff</summary>

```diff py
import anthropic

- client = anthropic.Client(os.environ["ANTHROPIC_API_KEY"])
+ client = anthropic.Anthropic()

# Streams are now incremental diffs of text
# rather than sending the whole message every time:
text = "
- stream = client.completion_stream(**params)
- for data in stream:
- diff = data["completion"].replace(text, "")
- text = data["completion"]
+ stream = client.completions.create(**params, stream=True)
+ for data in stream:
+ diff = data.completion # incremental text
+ text += data.completion
print(diff, end="")

print("Done. Final text is:")
print(text)
```

</details>

## Documentation

The API documentation can be found [here](https://docs.anthropic.com/claude/reference/).
Expand Down

0 comments on commit eec4574

Please sign in to comment.