AsyncCompletions Class — anthropic-sdk-python Architecture
Architecture documentation for the AsyncCompletions class in completions.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 239057dd_0ecb_e90d_0d61_ae3f0bfadde4["AsyncCompletions"] f98629a5_73f4_23f2_1f7f_c8db837848d1["AsyncAPIResource"] 239057dd_0ecb_e90d_0d61_ae3f0bfadde4 -->|extends| f98629a5_73f4_23f2_1f7f_c8db837848d1 f5340606_93f4_b0e0_a723_bb2136763e51["completions.py"] 239057dd_0ecb_e90d_0d61_ae3f0bfadde4 -->|defined in| f5340606_93f4_b0e0_a723_bb2136763e51 b85740cf_acfb_13af_8c4d_20f22920c4b1["with_raw_response()"] 239057dd_0ecb_e90d_0d61_ae3f0bfadde4 -->|method| b85740cf_acfb_13af_8c4d_20f22920c4b1 7d14b601_aec7_1ecc_e441_032a31e50410["with_streaming_response()"] 239057dd_0ecb_e90d_0d61_ae3f0bfadde4 -->|method| 7d14b601_aec7_1ecc_e441_032a31e50410 9c317a4f_95bc_c2b1_0575_0c4abd5aa170["create()"] 239057dd_0ecb_e90d_0d61_ae3f0bfadde4 -->|method| 9c317a4f_95bc_c2b1_0575_0c4abd5aa170
Relationship Graph
Source Code
src/anthropic/resources/completions.py lines 420–809
class AsyncCompletions(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncCompletionsWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
"""
return AsyncCompletionsWithRawResponse(self)
@cached_property
def with_streaming_response(self) -> AsyncCompletionsWithStreamingResponse:
"""
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
"""
return AsyncCompletionsWithStreamingResponse(self)
@overload
async def create(
self,
*,
max_tokens_to_sample: int,
model: ModelParam,
prompt: str,
metadata: MetadataParam | Omit = omit,
stop_sequences: SequenceNotStr[str] | Omit = omit,
stream: Literal[False] | Omit = omit,
temperature: float | Omit = omit,
top_k: int | Omit = omit,
top_p: float | Omit = omit,
betas: List[AnthropicBetaParam] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> Completion:
"""[Legacy] Create a Text Completion.
The Text Completions API is a legacy API.
We recommend using the
[Messages API](https://docs.claude.com/en/api/messages) going forward.
Future models and features will not be compatible with Text Completions. See our
[migration guide](https://docs.claude.com/en/api/migrating-from-text-completions-to-messages)
for guidance in migrating from Text Completions to Messages.
Args:
max_tokens_to_sample: The maximum number of tokens to generate before stopping.
Note that our models may stop _before_ reaching this maximum. This parameter
only specifies the absolute maximum number of tokens to generate.
model: The model that will complete your prompt.\n\nSee
[models](https://docs.anthropic.com/en/docs/models-overview) for additional
details and options.
prompt: The prompt that you want Claude to complete.
For proper response generation you will need to format your prompt using
alternating `\n\nHuman:` and `\n\nAssistant:` conversational turns. For example:
```
"\n\nHuman: {userQuestion}\n\nAssistant:"
```
See [prompt validation](https://docs.claude.com/en/api/prompt-validation) and
our guide to [prompt design](https://docs.claude.com/en/docs/intro-to-prompting)
for more details.
metadata: An object describing metadata about the request.
stop_sequences: Sequences that will cause the model to stop generating.
Our models stop on `"\n\nHuman:"`, and may include additional built-in stop
sequences in the future. By providing the stop_sequences parameter, you may
Domain
Defined In
Extends
Source
Frequently Asked Questions
What is the AsyncCompletions class?
AsyncCompletions is a class in the anthropic-sdk-python codebase, defined in src/anthropic/resources/completions.py.
Where is AsyncCompletions defined?
AsyncCompletions is defined in src/anthropic/resources/completions.py at line 420.
What does AsyncCompletions extend?
AsyncCompletions extends AsyncAPIResource.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free