MCPcopy
hub / github.com/openai/openai-python / create

Method create

src/openai/resources/completions.py:52–207  ·  view source on GitHub ↗

Creates a completion for the provided prompt and parameters. Returns a completion object, or a sequence of completion objects if the request is streamed. Args: model: ID of the model to use. You can use the [List models](https://platform.ope

(
        self,
        *,
        model: Union[str, Literal["gpt-3.5-turbo-instruct", "davinci-002", "babbage-002"]],
        prompt: Union[str, SequenceNotStr[str], Iterable[int], Iterable[Iterable[int]], None],
        best_of: Optional[int] | Omit = omit,
        echo: Optional[bool] | Omit = omit,
        frequency_penalty: Optional[float] | Omit = omit,
        logit_bias: Optional[Dict[str, int]] | Omit = omit,
        logprobs: Optional[int] | Omit = omit,
        max_tokens: Optional[int] | Omit = omit,
        n: Optional[int] | Omit = omit,
        presence_penalty: Optional[float] | Omit = omit,
        seed: Optional[int] | Omit = omit,
        stop: Union[Optional[str], SequenceNotStr[str], None] | Omit = omit,
        stream: Optional[Literal[False]] | Omit = omit,
        stream_options: Optional[ChatCompletionStreamOptionsParam] | Omit = omit,
        suffix: Optional[str] | Omit = omit,
        temperature: Optional[float] | Omit = omit,
        top_p: Optional[float] | Omit = omit,
        user: str | 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,
    )

Source from the content-addressed store, hash-verified

50
51 @overload
52 def create(
53 self,
54 *,
55 model: Union[str, Literal["gpt-3.5-turbo-instruct", "davinci-002", "babbage-002"]],
56 prompt: Union[str, SequenceNotStr[str], Iterable[int], Iterable[Iterable[int]], None],
57 best_of: Optional[int] | Omit = omit,
58 echo: Optional[bool] | Omit = omit,
59 frequency_penalty: Optional[float] | Omit = omit,
60 logit_bias: Optional[Dict[str, int]] | Omit = omit,
61 logprobs: Optional[int] | Omit = omit,
62 max_tokens: Optional[int] | Omit = omit,
63 n: Optional[int] | Omit = omit,
64 presence_penalty: Optional[float] | Omit = omit,
65 seed: Optional[int] | Omit = omit,
66 stop: Union[Optional[str], SequenceNotStr[str], None] | Omit = omit,
67 stream: Optional[Literal[False]] | Omit = omit,
68 stream_options: Optional[ChatCompletionStreamOptionsParam] | Omit = omit,
69 suffix: Optional[str] | Omit = omit,
70 temperature: Optional[float] | Omit = omit,
71 top_p: Optional[float] | Omit = omit,
72 user: str | Omit = omit,
73 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
74 # The extra values given here take precedence over values defined on the client or passed to this method.
75 extra_headers: Headers | None = None,
76 extra_query: Query | None = None,
77 extra_body: Body | None = None,
78 timeout: float | httpx.Timeout | None | NotGiven = not_given,
79 ) -> Completion:
80 """
81 Creates a completion for the provided prompt and parameters.
82
83 Returns a completion object, or a sequence of completion objects if the request
84 is streamed.
85
86 Args:
87 model: ID of the model to use. You can use the
88 [List models](https://platform.openai.com/docs/api-reference/models/list) API to
89 see all of your available models, or see our
90 [Model overview](https://platform.openai.com/docs/models) for descriptions of
91 them.
92
93 prompt: The prompt(s) to generate completions for, encoded as a string, array of
94 strings, array of tokens, or array of token arrays.
95
96 Note that <|endoftext|> is the document separator that the model sees during
97 training, so if a prompt is not specified the model will generate as if from the
98 beginning of a new document.
99
100 best_of: Generates `best_of` completions server-side and returns the "best" (the one with
101 the highest log probability per token). Results cannot be streamed.
102
103 When used with `n`, `best_of` controls the number of candidate completions and
104 `n` specifies how many to return – `best_of` must be greater than `n`.
105
106 **Note:** Because this parameter generates many completions, it can quickly
107 consume your token quota. Use carefully and ensure that you have reasonable
108 settings for `max_tokens` and `stop`.
109

Callers

nothing calls this directly

Calls 2

maybe_transformFunction · 0.85
make_request_optionsFunction · 0.85

Tested by

no test coverage detected